//
//  ViewController.m
//  digital_robot_demo
//
//  Created by xskj on 2024/8/29.
//

#import "ViewController.h"

#import "xsBossIPBottomTitleToolBarView.h"

#import "xsEditeDigitalRobotTitleView.h"
#import "xsDigitalRobotBottomView.h"

#import "xsChartletView.h"// 贴图
#import "xsTemplateView.h"// 模板

#import "xsBossIPBackgroundView.h"// 选择背景音乐
#import "xsTextView.h"// 文字
#import "xsBackgroundView.h"// 背景
#import "xsConfigurationMusicView.h"// 配音
#import "xsSelectBossTemplateView.h"//老板IP

#import "xsHadAddMaterialListView.h"

// 选择配音--音频参数view
#import "xsAudioConditioningSettingView.h"

// 选择添加素材
#import "xsSelectAddMaterialView.h"


#import "xsCropBaseView.h"
#import "xsCropBaseLabel.h"
#import "xsCropBaseImageView.h"

#import "TZImagePickerController.h"
#import "xsCropBaseButton.h"

#import <CoreText/CoreText.h>

#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import "UIView+XLLevelInView.h"
#import "xsBossIPChangeLevelView.h"
#import "xsBossIpBottomBaseView.h"

#import "xsBossIPOverlayView.h"
#import "xsRichTextClickView.h"

#define ScreenW UIScreen.mainScreen.bounds.size.width
#define ScreenH UIScreen.mainScreen.bounds.size.height
#define xrandomColor  [UIColor colorWithRed:(arc4random() %255)/255.0f green:(arc4random() %255)/255.0f blue:(arc4random() %255)/255.0f alpha:1.0f]
#define XSWeakSelf   __weak typeof(self) weakSelf = self;

//enum CropPosition: NSInteger {
//    case leftTop = 100
//    case rightTop = 101
//    case leftBottom = 102
//    case rightBottom = 103
//    case top = 104
//    case left = 105
//    case bottom = 106
//    case right = 107
//}
typedef enum : NSUInteger {
    leftTop = 100,
    rightTop = 101,
    leftBottom = 102,
    rightBottom = 103,
    top = 104,
    left = 105,
    bottom = 106,
    right = 107
} CropPosition;

typedef NS_ENUM(NSInteger,ImagePickerType) {
    ImagePickerTypePhotoLibrary,    // 图集
    ImagePickerTypePhotosAlbum,     // 照片库
    ImagePickerTypeCameraPhoto,     // 拍照
    ImagePickerTypeCameraVideo      // 录像
};

typedef enum : NSUInteger {
    CropView_imageV,
    CropView_label
} CropImageViewOrLabelType;


@interface ViewController ()<xsBossIPBottomTitleToolBarViewProtoCol,xsSelectBossTemplateViewProtoCol,xsConfigurationMusicViewProtoCol,xsTemplateViewProtoCol,xsBackgroundViewProtoCol,xsChartletViewProtoCol,xsBossIPBackgroundViewProtoCol,xsTextViewProtoCol,xsDigitalRobotBottomViewProtoCol,xsAudioConditioningSettingViewProtoCol,xsSelectAddMaterialViewProtoCol,TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,xsHadAddMaterialListViewProtoCol,xsEditeDigitalRobotTitleViewProtoCol,xsBossIPChangeLevelViewProtoCol>



//@property (nonatomic,assign)CGFloat bossTextKeyBordHeight;

//self.isToBigView = NO;
@property (nonatomic,assign) BOOL isToBigView;

@property (nonatomic,strong)xsBossIPChangeLevelView *xsBossIPChangeLevelV;
@property (nonatomic,strong)UIView *xsBossIPChangeLevelBackGroundView;

@property (nonatomic,weak)UIImageView *tempMirrorImageView;


//@property (weak, nonatomic) UIImageView *imageView;
@property (nonatomic, assign) ImagePickerType type;
@property (nonatomic, strong) UIImagePickerController *imagePicker;
@property (nonatomic, strong) AVPlayer *player;



@property (nonatomic,copy)NSString *xsNumberRobot_buildType;//  ":@(1),//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
@property (nonatomic,copy)NSString *xsNumberRobot_aspectRatio;//  ":@(1),//视频比例 1竖屏 2横屏
@property (nonatomic,copy)NSString *xsNumberRobot_smartHighlightingEnabled;//  ":@"",// 是否开启智能划重点 0 关闭 1 开启
@property (nonatomic,assign)CGFloat xsNumberRobot_width;//  ":@"",//视频宽度
@property (nonatomic,assign)CGFloat xsNumberRobot_height;//  ":@"",//视频高度

// 说话的那个人(数字人)
@property (nonatomic,copy)NSString *xsNumberRobot_backgroundImageUrl;//  ":@"",//背景图片地址
@property (nonatomic,copy)NSString *xsNumberRobot_backgroundColor;//  ":@"",//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
@property (nonatomic,strong)NSArray *xsNumberRobot_graphicalObjects;//  ":@[],//普通图形对象列表
@property (nonatomic,strong)NSArray *xsNumberRobot_textObjects;//  ":@[],//普通文本对象列表
@property (nonatomic,copy)NSString *xsNumberRobot_digitalHumanId;//  ":@"",//数字人id
@property (nonatomic,strong)xsSelectDigitalRobotCollectionViewCellModel *xsNumberRobot_digitalHumanModel;//记录选中数字人model
@property (nonatomic,strong)NSDictionary *xsNumberRobot_digitalHumanStyle;//  ":@"",//
@property (nonatomic,strong)NSDictionary *xsNumberRobot_materialStyle;//  ":@"",素材样式
@property (nonatomic,strong)NSArray *xsNumberRobot_materials;//  ":@[],//素材列表
@property (nonatomic,copy)NSString *xsNumberRobot_title;//  ":@"",//标题
@property (nonatomic,copy)NSString *xsNumberRobot_text;//  ":@"",//视频（字幕）内容
@property (nonatomic,strong)NSDictionary *xsNumberRobot_assStyle;//  ":@"",//字幕样式
@property (nonatomic,copy)NSString *xsNumberRobot_musicId;//  ":@"",//背景音乐id
@property (nonatomic,copy)NSString *xsNumberRobot_musicVolume;//  ":@"",//背景音乐音量
@property (nonatomic,copy)NSString *xsNumberRobot_voiceTemplateId;//  ":@"",//语音模板id
@property (nonatomic,copy)NSString *xsNumberRobot_digitalHumanVoiceId;//  ":@"",//数字人声音id
@property (nonatomic,copy)NSString *xsNumberRobot_speechRate;//  ":@"",//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
@property (nonatomic,copy)NSString *xsNumberRobot_volume;//  ":@""//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
@property (nonatomic,strong)NSDictionary *xsNumberRobot_titleStyle;// 标题样式



@property (nonatomic, strong) AVPlayer *ConfigurationBossPlayer;

@property (nonatomic,assign) CGFloat bottomTitleToolBarBgView_height;
@property (nonatomic,assign) CGFloat DigitalRobotBottomBgView_height;
@property (nonatomic,strong)UIView *topNavBarView;
@property (nonatomic,strong)UIButton *xsBackButton;
@property (nonatomic, strong) XSButton *xsPreviewButton;//预览
@property (nonatomic, strong) XSButton *xsExportButton;//导出
@property (nonatomic, strong) UILabel *xsExportButtonLabel;//导出

@property (nonatomic,strong)xsBossIpBottomBaseView *HadAddMaterialListVBgView;
// 已经选中的素材列表
@property (nonatomic,strong)xsHadAddMaterialListView *HadAddMaterialListV;


@property (nonatomic,assign) NSInteger xsCreateCropViewCout;
@property (nonatomic,assign)CropImageViewOrLabelType CropViewType;
//TestRobotCropViewTopLeftDeleteButtonsMarray记录的是四个角和四条边框住的view左上角的删除图标按钮
@property (nonatomic,strong)NSMutableArray *TestRobotCropViewTopLeftDeleteButtonsMarray;
//TestRobotCropViewMarray记录的是拖动的四个角和四条边  cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
@property (nonatomic,strong)NSMutableArray *TestRobotCropViewMarray;
//TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕  4及以上普通文本
@property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
// 记录点击页面上的控件 可能是 xsCropBaseLabel xsCropBaseImageView这两个
@property (nonatomic,weak) UIView *recordUserDragView;//


@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIScrollView *xsUnderneathBgScrollView;

///最小裁剪宽度
@property (nonatomic,assign) CGFloat minCropWidth;// 100
///最小裁剪高度
@property (nonatomic,assign) CGFloat minCropHeight;// 100
@property (nonatomic, strong) UIView *topImgBgView;
// 记录topImgBgView最小时的rect
@property (nonatomic,assign)CGRect topImgBgViewSmalRect;
// 记录topImgBgView最大时的rect
@property (nonatomic,assign)CGRect topImgBgViewBigRect;

//最底部的背景图不能拖动只能改变图像
@property (nonatomic, strong) UIImageView *bossBackgroundImage;//
// 记录topImgBgView最小时的rect
@property (nonatomic,assign)CGRect bossBackgroundImageSmalRect;
// 记录topImgBgView最大时的rect
@property (nonatomic,assign)CGRect bossBackgroundImageBigRect;

//遮罩 bossBackgroundImage四周的view的array
//    bossBackgroundImageLeftView    tag=0
//    bossBackgroundImageTopView     tag=1
//    bossBackgroundImageRightView   tag=2
//    bossBackgroundImageBottomView  tag=3
//    topCenterView                  tag=4
@property (nonatomic,strong)NSMutableArray *bossBackgroundImageZheZhaoMarr;


@property (nonatomic, strong) xsBossIpBottomBaseView *xsTextBgView;// 文字
@property (nonatomic, strong)xsTextView *xsTextView;
//字体类别事件
@property (nonatomic, strong) xsFontFamilyData *xsTexViewFontFamilyColModel;
//文字的背景颜色事件
@property (nonatomic, strong) xsFontStyleData *xsTexViewFontBackgroundColModel;
//文字颜色事件
@property (nonatomic, copy) NSString *xsTexViewTextColorHexString;
//文字描边事件
@property (nonatomic, copy) NSString *xsTexViewTextContourString;
//文字大小事件
@property (nonatomic, assign) CGFloat xsTexViewTextSizeF;





@property (nonatomic, strong) xsBossIpBottomBaseView *BossIPBackgroundViewBgView;// 选择背景音乐
@property (nonatomic, strong)xsBossIPBackgroundView *BossIPBackgroundView;
// //记录选中的背景音
@property (nonatomic,strong) xsBossIPBackgroundTableViewCellModel *xsBossIPBackgroundTableViewCellMd;

//选择背景音--音频参数view
@property (nonatomic,strong)xsAudioConditioningSettingView *xsBackgroundAudioConditioningSettingV;
@property (nonatomic,strong)xsBossIpBottomBaseView *xsBackgroundAudioConditioningSettingBgView;
//  背景音音量大小
@property (nonatomic,assign)CGFloat xsBackroundMusicAudioVolumeNumberF;


@property (nonatomic, strong) UIView *ChartletViewBgView;// 贴图
@property (nonatomic, strong)xsChartletView *ChartletViewView;


@property (nonatomic, strong) xsBossIpBottomBaseView *BackgroundViewBgView;// 背景
@property (nonatomic, strong)xsBackgroundView *BackgroundView;


@property (nonatomic, strong) xsBossIpBottomBaseView *templateViewViewBgView;// 模板
@property (nonatomic, strong)xsTemplateView *templateViewView;

// 记录选中的配音
@property (nonatomic,strong) xsConfigurationMusicCollectionViewCellModel *xsConfigurationMusicCollectionViewCellMd;
@property (nonatomic, strong) xsBossIpBottomBaseView *congfgonfigurationMusicBgView;// 配音
@property (nonatomic, strong)xsConfigurationMusicView *congfgonfigurationMusicView;


@property (nonatomic, strong) xsBossIpBottomBaseView *digitalRobotViewBgView;// 选择数字人背景
@property (nonatomic, strong)xsSelectBossTemplateView *DigitalRobotView;



@property (nonatomic, strong) UIView *bottomTitleToolBarBgView;// 编辑数字人时 对应的标题小标题数字人背景样式

@property (nonatomic, strong)UIView *xsEditeDigitalRobotTitleVBgView;
@property (nonatomic, strong)xsEditeDigitalRobotTitleView *EditeDigitalRobotTitleV;

@property (nonatomic,strong)NSArray *DigitalRobotBottomTitleToolBarViewArray;
@property (nonatomic,strong)NSArray *DigitalRobotBottomTitleToolBarViewIconArray;

@property (nonatomic,strong)UIView *DigitalRobotBottomBgView;// 底部综合的view
@property (nonatomic,strong) xsDigitalRobotBottomView *RobotBottomView;

//  音频参数
@property (nonatomic,strong)UIView * xsAudioConditioningSettingBgView;
@property (nonatomic,strong)xsAudioConditioningSettingView *xsAudioConditioningSettingV;
//  音量大小
@property (nonatomic,assign)CGFloat xsAudioVolumeNumberF;
//  语速快慢
@property (nonatomic,assign)CGFloat xsLanguageSpeedNumberF;



// 选择添加素材
@property (nonatomic,strong)xsBossIpBottomBaseView * xsSelectAddMaterialBgView;
@property (nonatomic,strong)xsSelectAddMaterialView *xsSelectAddMaterialV;
// 选中的素材
@property (nonatomic,strong)NSMutableArray *xsSelectAddMaterialModelMarray;

// 记录底部显示的弹框
// tag  0老板IP  1配音  2背景  3文字  4音乐
@property (nonatomic,strong)NSMutableArray *xsRecrodBottomShowPanViewMarray;



@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    


//    bearer c5f0e7e2-06f1-4ef1-9c4b-ad9c68efe250
    [[NSUserDefaults standardUserDefaults] setObject:@"bearer 6e1c3a25-178b-45f2-857c-a6555a88d0f0" forKey:@"token"];
    [[NSUserDefaults standardUserDefaults] synchronize];


    [self createUI];

    // 获取所有字体族（family）的名称
//    NSArray *fontFamilies = [UIFont familyNames];

//    // 遍历每个字体族
//    for (NSString *familyName in fontFamilies) {
//        // 打印字体族名称
//        NSLog(@"Font Family: %@", familyName);
//
//        // 获取该字体族中所有字体的名称
//        NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
//
//        // 遍历并打印每个字体的名称
//        for (NSString *fontName in fontNames) {
//            NSLog(@"  Font: %@", fontName);
//        }
//    }

//// 测试图片镜像
//[self xlTestImageViewJingXinag];
    
//    //测试富文本中点击输入停顿秒数
//    [self xsTestKongJian];
    
}
// 测试富文本中点击输入停顿秒数
- (void)xsTestKongJian{
    xsRichTextClickView *RichTextClickView =[[xsRichTextClickView alloc] initWithFrame:CGRectMake(0, 160, self.view.width, 290)];
    [self.view addSubview:RichTextClickView];
    RichTextClickView.backgroundColor = UIColor.whiteColor;
}

#pragma mark 测试图片镜像
- (void)xlTestImageViewJingXinag{
    
    // 556  516
    CGFloat imageViewW = 556.0*0.5;
    CGFloat imageViewH = 516.0*0.5;
    CGFloat imageViewX = (kScreenWidth-imageViewW)*0.5;
    CGFloat imageViewY = (kScreenHeight-imageViewH)*0.5;
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xsbossmnv"]];
    imageView.frame = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH); // 假设的frame，根据需要调整
    //imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
    self.tempMirrorImageView = imageView;
    [self.view addSubview:imageView]; // 假设self.view是你的主视图
    
    
    
    XSWeakSelf;
    
    
    
    CGFloat painterButtonY = CGRectGetMaxY(imageView.frame)+20;
    CGFloat painterButtonW = 90;
    CGFloat painterButtonH = 40;
    CGFloat painterButtonX = (kScreenW-painterButtonW)*0.5;
    XSButton *painterButton = [XSButton buttonWithType:UIButtonTypeCustom];
    painterButton.backgroundColor = UIColor.redColor;
    painterButton.titleLabel.font = FontBoldMT(14);
    [painterButton setTitle:kLocalizedString(@"镜像图片") forState:UIControlStateNormal];
    [painterButton setTitleColor:COLOR_White forState:UIControlStateNormal];
    painterButton.tag = 0;
    painterButton.selected = NO;
    [self.view addSubview:painterButton];
    painterButton.frame = CGRectMake(painterButtonX, painterButtonY, painterButtonW, painterButtonH);
    [painterButton addTapRunWithBlock:^(XSButton * _Nonnull YSBtn) {
        NSLog(@"painterButton addTapRunWithBlock");
        
        YSBtn.selected = !YSBtn.selected;
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf MirrorImageFunction:YSBtn.selected];
        });
        
    }];
}

- (void)MirrorImageFunction:(BOOL)isSelectState{
    if(isSelectState){
         
        
        self.tempMirrorImageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
    }
    else{
        self.tempMirrorImageView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    }
    
}

- (void)xsConfigDefaultDataP{
    
    
    self.CropViewType = CropView_imageV;
    ///最小裁剪宽度
    self.minCropWidth = 30;//100;
    ///最小裁剪高度
    self.minCropHeight = 30;//100;
    
    
    //self.xsAudioVolumeNumberF = 50;
    //self.xsLanguageSpeedNumberF = 1.0;
    self.xsBackroundMusicAudioVolumeNumberF = 50;//0.5;
    
    //背景音乐音量
    self.xsNumberRobot_musicVolume = @"50";//
    
    ////视频比例 1竖屏 2横屏
    self.xsNumberRobot_aspectRatio = @"1";
    
    // 是否开启智能划重点 0 关闭 1 开启
    self.xsNumberRobot_smartHighlightingEnabled = @"0";
    
    
    
    self.xsAudioVolumeNumberF = 50;
    self.xsLanguageSpeedNumberF = 1.0;
    
//    // 声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
//    self.xsNumberRobot_speechRate = [NSString stringWithFormat:@"%.1f",self.xsLanguageSpeedNumberF];
    //声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
    self.xsNumberRobot_speechRate = @"1.0";
    //  ":@""//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
    self.xsNumberRobot_volume = @"50";
    
    // 视频比例 aspectRatio    视频比例 现在只有竖屏 传1就行   categoryId： 1是男的 2是女的 0是全部
    [self getNumberPeopleDataWithAspectRatio:1 withCategoryId:0];
    
    //self.bossTextKeyBordHeight = 0.0;
// 注册键盘通知
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWillShow:)
                                             name:UIKeyboardWillShowNotification
                                           object:nil];
  
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWillHide:)
                                             name:UIKeyboardWillHideNotification
                                           object:nil];
 
}
//UNI_EXPORT_METHOD(@selector(onReady:))
- (void)onReady:(NSDictionary *)Paramer {
    // Paramer 为前端传递的参数
    NSLog(@"onReady--Paramer==%@\n",Paramer);
    
    [self xsConfigDefaultDataP];
}

#pragma mark  键盘通知处理方法
- (void)keyboardWillShow:(NSNotification *)notification {
    NSDictionary *userInfo = [notification userInfo];
      
    
//    CGSize keyboardSize = [[userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] size];
//
//    // 更新自定义视图的frame
//    CGRect frame = self.customView.frame;
//    frame.origin.y -= keyboardSize.height;
//    self.customView.frame = frame;
    
    CGSize keyboardSize = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    
    NSLog(@"keyboardSize==%@\n",NSStringFromCGSize(keyboardSize));
////    keyboardSize=={375, 292}
    if(self.xsTextBgView.xsIsShow){
        
        CGFloat xsTextViewBgViewW = ScreenW;
        CGFloat xsTextViewBgViewH = 370.0;
        CGFloat xsTextViewBgViewX = 0;
        //CGFloat xsTextViewBgViewY = ScreenH;//-xsTextViewBgViewH;
        
//        if(tag==0){// 键盘
//            xsTextViewBgViewH = 110.0;
//        }
//        else{//  样式
//            xsTextViewBgViewH = 370.0;
//        }
        
        
//            CGRect frame = self.xsTextBgView.frame;
//            frame.origin.y -= keyboardSize.height;
//            self.xsTextBgView.frame = frame;
        
        if(self.xsTextView.ClickButtonStyle==bossTopTextClickButtonStyle_keybord){
            
            xsTextViewBgViewH = 110.0+ keyboardSize.height;
            
            CGFloat xsTextViewBgViewY = ScreenH-xsTextViewBgViewH;
            self.xsTextBgView.frame = CGRectMake(0,xsTextViewBgViewY, xsTextViewBgViewW, xsTextViewBgViewH);
            NSLog(@"键盘键盘键盘键盘键盘");
        }
        else if(self.xsTextView.ClickButtonStyle==bossTopTextClickButtonStyle_style){
            CGFloat topViewH = 110;
            CGFloat tempHeight = keyboardSize.height+topViewH;
            CGFloat xsTextViewBgViewY = ScreenH-tempHeight;
            self.xsTextBgView.frame = CGRectMake(0,xsTextViewBgViewY, xsTextViewBgViewW, tempHeight);
            [_xsTextView xsChangeKeyBordStyleLineViewLocationWithTag:0];
            NSLog(@"样式样式样式样式样式");
        }
        
    }
}
  
- (void)keyboardWillHide:(NSNotification *)notification {
//    // 恢复自定义视图的原始位置
//    CGRect frame = self.customView.frame;
//    frame.origin.y += [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//    self.customView.frame = frame;
    CGFloat y =  [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
    NSLog(@"keyboardSize--y==%f\n",y);
    //keyboardSize--y==292.000000
//
//    if(self.xsTextBgView.xsIsShow){
//
//        CGRect frame = self.xsTextBgView.frame;
//        frame.origin.y += [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//        self.xsTextBgView.frame = frame;
//    }
    
    if(self.xsTextBgView.xsIsShow){
        
        CGFloat xsTextViewBgViewW = ScreenW;
        CGFloat xsTextViewBgViewH = 370.0;
        CGFloat xsTextViewBgViewX = 0;
        //CGFloat xsTextViewBgViewY = ScreenH;//-xsTextViewBgViewH;
        
//        if(tag==0){// 键盘
//            xsTextViewBgViewH = 110.0;
//        }
//        else{//  样式
//            xsTextViewBgViewH = 370.0;
//        }
        if(self.xsTextView.ClickButtonStyle==bossTopTextClickButtonStyle_keybord){
            
            xsTextViewBgViewH = 110.0;
            CGFloat xsTextViewBgViewY = ScreenH-xsTextViewBgViewH;
            self.xsTextBgView.frame = CGRectMake(0, xsTextViewBgViewY, xsTextViewBgViewW, xsTextViewBgViewH);
        }
        else if(self.xsTextView.ClickButtonStyle==bossTopTextClickButtonStyle_style){
        
        }
        
    }
    
}
- (void)dealloc {
    // 移除键盘通知
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
  
#pragma mark 设置视频文案文字
// 通过 WX_EXPORT_METHOD 将方法暴露给前端
//UNI_EXPORT_METHOD(@selector(xsChangeBossIPAppVideoText:))
- (void)xsChangeBossIPAppVideoText:(NSDictionary *)options {
    // options 为前端传递的参数
    NSLog(@"%@",options);
    
    if([options isKindOfClass:[NSDictionary class]]){
        NSString *bossIpVideoTextStr = options[@"bossIpVideoText"];
        if(!kStringIsEmpty(bossIpVideoTextStr)){
//            // 设置视频文案文字
//            - (void)xsChangeInputCopywritingTextVWithString:(NSString *)textStr
            self.xsNumberRobot_text = bossIpVideoTextStr;
            [self.RobotBottomView xsChangeInputCopywritingTextVWithString:bossIpVideoTextStr];
            
            [self xsChangeSubtitlesText:bossIpVideoTextStr];
            
            
            [self xsMaterialIsHiden:NO];
            [_RobotBottomView xsChangeMaterialButtonIsClick:YES];
        }
    }
    
    
    
    [YSHelp wqWriteData:[NSString stringWithFormat:@"viewWillLoad6662--self.TestRobotCropCurrentMarray.count==%ld    self.TestRobotCropCurrentMarray==%@",self.TestRobotCropCurrentMarray.count,self.TestRobotCropCurrentMarray] withFileName:@"viewWillLoad6666--22"];
//    [self addObserverButtonHandler];
    
  
    if(self.TestRobotCropCurrentMarray.count>0){
        
        
        for (int i=0;i<self.TestRobotCropCurrentMarray.count;i++) {
            xsCropBaseView *tempCropCurrentView = self.TestRobotCropCurrentMarray[i];
            
            xsCropBaseView *findCropView;
            for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
                xsCropBaseView *tempCropV = self.TestRobotCropViewMarray[i];
                if(tempCropV.cropTag==tempCropCurrentView.cropTag){
                    findCropView = tempCropV;
                    break;
                }
            }
            
            xsCropBaseButton *findDeleteButton;
            for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
                xsCropBaseButton *tempDeleteButton = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
                if(tempDeleteButton.cropTag==tempCropCurrentView.cropTag){
                    findDeleteButton = tempDeleteButton;
                    break;
                }
            }
            [YSHelp wqWriteData:[NSString stringWithFormat:@"viewWillLoad6662--tempCropCurrentView==%@",tempCropCurrentView] withFileName:@"viewWillLoad6666--222222"];
            if(findCropView){
                [self.topImgBgView insertSubview:findCropView aboveSubview:tempCropCurrentView];
                findCropView.hidden = NO;
//                findCropView.backgroundColor = UIColor.orangeColor;
//                findCropView.alpha = 0.45;
                
                [YSHelp wqWriteData:[NSString stringWithFormat:@"viewWillLoad6662--findCropView==%@",findCropView] withFileName:@"viewWillLoad6666--333"];
            }
            if(findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:tempCropCurrentView];
                [YSHelp wqWriteData:[NSString stringWithFormat:@"viewWillLoad6662--findDeleteButton==%@",findDeleteButton] withFileName:@"viewWillLoad6666--4444"];
            }
        }
        
    }
}
#pragma mark 设置字幕label文字
- (void)xsChangeSubtitlesText:(NSString *)sbTextString{
    
    //    *TestRobotCropViewMarray;// 0数字人  1素材 2标题 3字幕
    //    *TestRobotCropCurrentMarray;//  0数字人  1素材 2标题 3字幕
        
        for(xsCropBaseView *tempCropItem in self.TestRobotCropViewMarray){
            if(tempCropItem.cropTag!=3){
                tempCropItem.hidden = YES;
            }
            else{
                tempCropItem.hidden = NO;
            }
        }
        for(xsCropBaseLabel *tempCropItem in self.TestRobotCropCurrentMarray){
            if(tempCropItem.cropTag==3){
                //tempCropItem.text = [sbTextString copy];
                tempCropItem.recodeBaseStr = [sbTextString copy];
                [self xsTextUpdateTextFontStyleWith:tempCropItem];
                break;
            }
        }
}

#pragma mark 前端上传图片或者文件成功  bossipType 0图片 2视频
//UNI_EXPORT_METHOD(@selector(bossIPUniappVueSetImageOrVideoSuccess:))
- (void)bossIPUniappVueSetImageOrVideoSuccess:(NSDictionary *)Paramer {
    // Paramer 为前端传递的参数
    NSLog(@"bossIPUniappVueSetImageOrVideoSuccess--Paramer==%@\n",Paramer);
    if([Paramer isKindOfClass:[NSDictionary class]]){
        NSInteger bossipTypeInt = [Paramer[@"bossipType"] intValue];
        
        if(bossipTypeInt==0){
            if(_xsSelectAddMaterialV){
                
                //collectionType;// 0全部 3图片 1视频
                [_xsSelectAddMaterialV bossIPUniappVuePageUploadImageOrVideoSuccessfulWith:3];
            }
        }
        else if(bossipTypeInt==2){
            //collectionType;// 0全部 3图片 1视频
            [_xsSelectAddMaterialV bossIPUniappVuePageUploadImageOrVideoSuccessfulWith:1];
        }
    }
}

#pragma mark 前端上删除素材成功  bossDeleteId 删除的素材Id
//UNI_EXPORT_METHOD(@selector(bossIPUniappVueDeleteMaterialSuccess:))
- (void)bossIPUniappVueDeleteMaterialSuccess:(NSDictionary *)Paramer {
    // Paramer 为前端传递的参数
    NSLog(@"bossIPUniappVueDeleteMaterialSuccess--Paramer==%@\n",Paramer);
        
    if([Paramer isKindOfClass:[NSDictionary class]]){
        NSInteger bossipTypeInt = [Paramer[@"bossDeleteId"] integerValue];
        [_xsSelectAddMaterialV xsSelectAddMaterialVUniappVueDeleteMaterialSuccessWithId:bossipTypeInt];
    }
}




- (UIImageView *)bossBackgroundImage{
    
    if(!_bossBackgroundImage){
        _bossBackgroundImage = [[UIImageView alloc] init];
        _bossBackgroundImage.backgroundColor = COLOR_HEX(0x313032);//UIColor.clearColor;
    }
    return _bossBackgroundImage;
}

- (NSMutableArray *)xsSelectAddMaterialModelMarray{
    if(!_xsSelectAddMaterialModelMarray){
        _xsSelectAddMaterialModelMarray = [[NSMutableArray alloc] init];
    }
    return _xsSelectAddMaterialModelMarray;
}

- (void)createTopView{
    self.bottomTitleToolBarBgView_height = 55.0+kIPhoneBottom_Height;
    self.DigitalRobotBottomBgView_height = ScreenH * 0.4;
    
    
    [self.bgView addSubview:self.topImgBgView];

//CGFloat tempBottomViewHeight = self.bottomTitleToolBarBgView.height+self.DigitalRobotBottomBgView.height;

    
    CGFloat tempBottomViewHeight = self.bottomTitleToolBarBgView_height+self.DigitalRobotBottomBgView_height;

    
    //375  667
    CGFloat topImgBgViewW = ScreenW;
    CGFloat topImgBgViewX = 0;
    CGFloat topImgBgViewY = kNavigationBar_Height;//0;
    CGFloat topImgBgViewH = ScreenH - tempBottomViewHeight-topImgBgViewY;//ScreenH - 350-topImgBgViewY;
    
    self.xsTexViewTextSizeF = 16.0;

         
    self.topImgBgView.frame = CGRectMake(topImgBgViewX, topImgBgViewY, topImgBgViewW, topImgBgViewH);
    self.topImgBgViewSmalRect = self.topImgBgView.frame;

    
// 获取self.topImgBgView.frame  16:9最佳宽高
    CGFloat loveW9  = 9.0;
    CGFloat loveH16 = 16.0;
    BOOL xsIsBrek = NO;
    CGFloat count = 1.0;
    while (!xsIsBrek) {
            
        CGFloat tempLoveW9 = loveW9 *count;
        CGFloat tempLoveH16 = loveH16 *count;
        if((tempLoveW9<topImgBgViewW)&&(tempLoveH16<topImgBgViewH)){
            count++;
        }
        else{
            xsIsBrek = YES;
        }
    }
    count = count-1;
    
    //计算数字人最大能显示的大小
    [self bsCalculateDigitalRobotCanShowBigWH];
    
    self.xsNumberRobot_width = loveW9*count;
    self.xsNumberRobot_height = loveH16*count;
    
    CGFloat robotTopHeight = self.topImgBgView.height;
    
    CGFloat robitItemViewY = (self.topImgBgView.height-self.xsNumberRobot_height)*0.5;
    
    
    CGFloat bossBackgroundImageX = (self.topImgBgView.width-self.xsNumberRobot_width)*0.5;
    CGFloat bossBackgroundImageY = (robotTopHeight-self.xsNumberRobot_height)*0.5;
    [self.topImgBgView addSubview:self.bossBackgroundImage];
    self.bossBackgroundImage.frame = CGRectMake(bossBackgroundImageX, bossBackgroundImageY, self.xsNumberRobot_width, self.xsNumberRobot_height);
    self.bossBackgroundImageSmalRect = self.bossBackgroundImage.frame;
    
    self.xsCreateCropViewCout = 0;

    
    [self xsTestRobotCropImageViewWithCropTag:self.xsCreateCropViewCout withImgOrLabel:CropView_imageV withImageSource:@"bossIPDefaultImage" withTitle:nil withOffsetY:robitItemViewY];
    
    ++self.xsCreateCropViewCout;
    [self xsTestRobotCropImageViewWithCropTag:self.xsCreateCropViewCout withImgOrLabel:CropView_imageV withImageSource:@"bossIPDefaultImage" withTitle:nil withOffsetY:robitItemViewY];//robitItemViewY+30
    
    ++self.xsCreateCropViewCout;
    CGFloat cropLabelY = robitItemViewY;//robitItemViewY+30;
    [self xsTestRobotCropImageViewWithCropTag:self.xsCreateCropViewCout withImgOrLabel:CropView_label withImageSource:nil withTitle:@"请输入标题" withOffsetY:cropLabelY];
    
    ++self.xsCreateCropViewCout;
    [self xsTestRobotCropImageViewWithCropTag:self.xsCreateCropViewCout withImgOrLabel:CropView_label withImageSource:nil withTitle:@"添加字幕" withOffsetY:cropLabelY];//cropLabelY+50
    
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
    //查找当前被选中的label或者imageview
    [self xsFindUserDragViewWithCropTage:0];
    
    
    
    
    [self xsTopNavBarView];
////创建背景图片四周遮罩的view
//[self xsCreateBossBackgroundImageLeftTopRightBottom];
}

- (void)xsTopNavBarView
{
    [self.bgView addSubview:self.topNavBarView];
    [self.topNavBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.bgView);
        make.height.mas_equalTo(kStatusBar_Height+44.0);
    }];
    [self.topNavBarView addSubview:self.xsBackButton];//
    [self.topNavBarView addSubview:self.xsExportButton];//导出
    [self.topNavBarView addSubview:self.xsPreviewButton];//预览
    
    
    CGFloat margin15 = 15.0;
    
    //
    [self.xsBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.topNavBarView.mas_left);//.offset(-margin15);
        make.top.equalTo(self.topNavBarView.mas_top).offset(kStatusBar_Height);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    
    
   //CGFloat xsExportButtonY = kStatusBar_Height+(40-28)*0.5;
    // 导出
    [self.xsExportButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.topNavBarView.mas_right).offset(-margin15);
//        make.top.equalTo(self.bgView.mas_top).offset(xsExportButtonY);
        make.centerY.equalTo(self.xsBackButton.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(53, 28));
    }];
    self.xsExportButton.layer.cornerRadius = 4.0;
    self.xsExportButton.layer.masksToBounds = YES;
    CAGradientLayer *xsExportButtongradientLayer = [CAGradientLayer layer];
    xsExportButtongradientLayer.frame = CGRectMake(0, 0, 53, 28);
    xsExportButtongradientLayer.startPoint = CGPointMake(0.0,0.5);
    xsExportButtongradientLayer.endPoint = CGPointMake(1.0,0.5);
    //gradientLayer.locations = @[@(0.5), @(0.0)];
    xsExportButtongradientLayer.colors = @[(id)COLOR_HEX(0x7F6DF3).CGColor,
                             (id)COLOR_HEX(0x1656F3).CGColor];
    [self.xsExportButton.layer addSublayer:xsExportButtongradientLayer];
//    [self.xsExportButton setTitle:kLocalizedString(@"导出") forState:UIControlStateNormal];
//    [self.xsExportButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    //self.xsExportButton.font = Font(16);
    [self.xsExportButton addSubview:self.xsExportButtonLabel];
    [self.xsExportButtonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.xsExportButton);//.offset(-margin15);
    }];
    
    //
    [self.xsPreviewButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.xsExportButton.mas_left).offset(-margin15);
        make.centerY.equalTo(self.xsExportButton.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(53, 28));
    }];
    self.xsPreviewButton.layer.cornerRadius = 4.0;
    self.xsPreviewButton.layer.masksToBounds = YES;
}

#pragma mark  计算数字人最大能显示的大小
- (void)bsCalculateDigitalRobotCanShowBigWH{
    
    
    CGFloat LevelBackGroundVH = 160;
    if(_xsBossIPChangeLevelBackGroundView){
        LevelBackGroundVH = _xsBossIPChangeLevelBackGroundView.height;
    }
    
    CGFloat topImgBgViewW = kScreenW;
    CGFloat topImgBgViewH = kScreenH-kStatusBarHeight-LevelBackGroundVH;
    
    CGFloat loveW9  = 9.0;
    CGFloat loveH16 = 16.0;
    BOOL xsIsBrek = NO;
    CGFloat count = 1.0;
    while (!xsIsBrek) {
            
        CGFloat tempLoveW9 = loveW9 *count;
        CGFloat tempLoveH16 = loveH16 *count;
        
//        if(count==21){
//            NSLog(@"tempLoveW9==%f\n",tempLoveW9);
//            NSLog(@"tempLoveH16==%f\n",tempLoveH16);
//            int a = 10;
//        }
        if((tempLoveW9<topImgBgViewW)&&(tempLoveH16<topImgBgViewH)){
            count= count + 0.1;
        }
        else{
            xsIsBrek = YES;
        }
        
    }
    
    count = count-0.1;
    
    
    CGFloat tempLoveBigW = loveW9 *count;
    CGFloat tempLoveBigH = loveH16 *count;
    
    
    
    NSLog(@"bsCalculateDigitalRobotCanShowBigWH--Width==%f\n",tempLoveBigW);
    NSLog(@"bsCalculateDigitalRobotCanShowBigWH--height==%f\n",tempLoveBigH);
    
//    bsCalculateDigitalRobotCanShowBigWH--Width==273.600000
//    bsCalculateDigitalRobotCanShowBigWH--height==486.400000
    
    self.topImgBgViewBigRect = CGRectMake(0, kStatusBarHeight, kScreenW, tempLoveBigH);
    //bossBackgroundImage 是topImgBgView的子view 所以x y得重算
    CGFloat tempbossBackgroundImageBigX = (kScreenW-tempLoveBigW)*0.5;
    CGFloat tempbossBackgroundImageBigY = 0;
    self.bossBackgroundImageBigRect = CGRectMake(tempbossBackgroundImageBigX, tempbossBackgroundImageBigY, tempLoveBigW, tempLoveBigH);
    
    NSLog(@"kScreenW--kScreenW==%f\n",kScreenW);
    NSLog(@"kScreenH--kScreenH==%f\n",kScreenH);
    
//    kScreenW--kScreenW==375.000000
//    kScreenH--kScreenH==667.000000
}

#pragma mark 创建背景图片四周遮罩的view
- (void)xsCreateBossBackgroundImageLeftTopRightBottom{
    
    //self.bossBackgroundImage
    //self.topImgBgView
    
    CGFloat bossBackgroundImageLeftViewX = 0;
    CGFloat bossBackgroundImageLeftViewY = self.topImgBgView.frame.origin.y;
    CGFloat bossBackgroundImageLeftViewW = self.bossBackgroundImage.frame.origin.x;
    CGFloat bossBackgroundImageLeftViewH = self.topImgBgView.height;
    UIView *bossBackgroundImageLeftView = [[UIView alloc] init];
    bossBackgroundImageLeftView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:bossBackgroundImageLeftView];
    bossBackgroundImageLeftView.frame = CGRectMake(bossBackgroundImageLeftViewX, bossBackgroundImageLeftViewY, bossBackgroundImageLeftViewW, bossBackgroundImageLeftViewH);
    bossBackgroundImageLeftView.tag = 0;
    
    
    CGFloat topCenterViewX = 40;//CGRectGetMaxX(self.xsBackButton.frame);
    CGFloat topCenterViewW =self.bgView.width-136-topCenterViewX;//15-53-15-53
    CGFloat topCenterViewH = CGRectGetMinY(bossBackgroundImageLeftView.frame);
    UIView *topCenterView = [[UIView alloc] init];
    topCenterView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:topCenterView];
    topCenterView.frame = CGRectMake(topCenterViewX, 0, topCenterViewW, topCenterViewH);
    topCenterView.tag = 4;
    
    CGFloat bossBackgroundImageTopViewX = 0;
    CGFloat bossBackgroundImageTopViewY = self.topImgBgView.frame.origin.y;
    CGFloat bossBackgroundImageTopViewW = self.bgView.width;
    CGFloat bossBackgroundImageTopViewH = self.bossBackgroundImage.frame.origin.y;
    UIView *bossBackgroundImageTopView = [[UIView alloc] init];
    bossBackgroundImageTopView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:bossBackgroundImageTopView];
    bossBackgroundImageTopView.frame = CGRectMake(bossBackgroundImageTopViewX, bossBackgroundImageTopViewY, bossBackgroundImageTopViewW, bossBackgroundImageTopViewH);
    bossBackgroundImageTopView.tag = 1;
    
    CGFloat bossBackgroundImageRightViewX = CGRectGetMaxX(self.bossBackgroundImage.frame);
    CGFloat bossBackgroundImageRightViewY = self.topImgBgView.frame.origin.y;
    CGFloat bossBackgroundImageRightViewW = self.topImgBgView.width-bossBackgroundImageRightViewX;
    CGFloat bossBackgroundImageRightViewH = self.topImgBgView.height;
    UIView *bossBackgroundImageRightView = [[UIView alloc] init];
    bossBackgroundImageRightView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:bossBackgroundImageRightView];
    bossBackgroundImageRightView.frame = CGRectMake(bossBackgroundImageRightViewX, bossBackgroundImageRightViewY, bossBackgroundImageRightViewW, bossBackgroundImageRightViewH);
    bossBackgroundImageRightView.tag = 2;
    
    CGFloat bossBackgroundImageBottomViewX = 0;
    CGFloat bossBackgroundImageBottomViewY = CGRectGetMaxY(self.bossBackgroundImage.frame)+self.topImgBgView.frame.origin.y;
    CGFloat bossBackgroundImageBottomViewW = self.topImgBgView.width;
    CGFloat bossBackgroundImageBottomViewH = self.topImgBgView.height-CGRectGetMaxY(self.bossBackgroundImage.frame);
    UIView *bossBackgroundImageBottomView = [[UIView alloc] init];
    bossBackgroundImageBottomView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:bossBackgroundImageBottomView];
    bossBackgroundImageBottomView.frame = CGRectMake(bossBackgroundImageBottomViewX, bossBackgroundImageBottomViewY, bossBackgroundImageBottomViewW, bossBackgroundImageBottomViewH);
    bossBackgroundImageBottomView.tag = 3;
    
    
    //xsBackButton
//    [self.xsBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.bgView.mas_left);//.offset(-margin15);
//        make.top.equalTo(self.bgView.mas_top).offset(kStatusBar_Height);
//        make.size.mas_equalTo(CGSizeMake(40, 40));
//    }];
    //xsBackButton会显示一点点删除图片lefttop那个按钮 所以要遮罩一层view
    CGFloat xsBackButtonTopViewX = 0;//CGRectGetMaxX(self.xsBackButton.frame);
    CGFloat xsBackButtonTopViewY = kStatusBar_Height+40-8.0;
    CGFloat xsBackButtonTopViewW =40;//15-53-15-53
    CGFloat xsBackButtonTopViewH = topCenterView.height-xsBackButtonTopViewY;
    UIView *xsBackButtonTopView = [[UIView alloc] init];
    xsBackButtonTopView.backgroundColor = COLOR_Black;
    [self.bgView addSubview:xsBackButtonTopView];
    xsBackButtonTopView.frame = CGRectMake(xsBackButtonTopViewX, xsBackButtonTopViewY, xsBackButtonTopViewW, xsBackButtonTopViewH);
    xsBackButtonTopView.tag = 6;
    
    
//    bossBackgroundImageLeftView    tag=0
//    bossBackgroundImageTopView     tag=1
//    bossBackgroundImageRightView   tag=2
//    bossBackgroundImageBottomView  tag=3
//    topCenterView                  tag=4
    [self.bossBackgroundImageZheZhaoMarr addObject:bossBackgroundImageLeftView];
    [self.bossBackgroundImageZheZhaoMarr addObject:bossBackgroundImageTopView];
    [self.bossBackgroundImageZheZhaoMarr addObject:bossBackgroundImageRightView];
    [self.bossBackgroundImageZheZhaoMarr addObject:bossBackgroundImageBottomView];
    [self.bossBackgroundImageZheZhaoMarr addObject:topCenterView];
    [self.bossBackgroundImageZheZhaoMarr addObject:xsBackButtonTopView];
    
}

- (void)createUI{
    
    
    [self.view addSubview:self.xsUnderneathBgScrollView];
    self.xsUnderneathBgScrollView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
    
   
    
//[self.view addSubview:self.bgView];
////[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
////    make.left.top.right.equalTo(self.view);
////    //make.top.equalTo(self.navBarview.mas_bottom);
//////        make.bottom.equalTo(self.view.mas_bottom).offset(-kIPhoneBottom_Height);
////    make.bottom.equalTo(self.view.mas_bottom);//.offset(-kIPhoneBottom_Height);
////}];
//self.bgView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
    
    [self onReady:nil];
    [self.xsUnderneathBgScrollView addSubview:self.bgView];
    //[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
    //    make.left.top.right.equalTo(self.view);
    //    //make.top.equalTo(self.navBarview.mas_bottom);
    ////        make.bottom.equalTo(self.view.mas_bottom).offset(-kIPhoneBottom_Height);
    //    make.bottom.equalTo(self.view.mas_bottom);//.offset(-kIPhoneBottom_Height);
    //}];
    self.bgView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
    
    
    
    
    

    
    //@[@"老板IP",@"配音",@"背景",@"文字",@"音乐"]
    //[self bottomToolBarTest];// 底部按钮
    
    //数字人Collection
    //[self digitalRobotViewTest];//数字人
    
    [self createTopView];
    [self xsBottomView];
    
    
////    xsEditeDigitalRobot_bigTitle,// 大标题                  --->对应    编辑 样式 气泡 动画 层级
////    xsEditeDigitalRobot_smallTitle,// 小标题                --->对应    样式 气泡 动画 层级
////    xsEditeDigitalRobot_backgroundImg, // 背景图像                  --->对应    层级 镜像 删除
////    xsEditeDigitalRobot_digitalRobotImg // 机器人图像        --->对应    更换形象  层级 镜像 删除
////编辑大标题 小标题 背景图片 数字机器人图片
//[self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_bigTitle];
}


- (void)xsBottomView{
    

    
    
    //@[@"老板IP",@"配音",@"背景",@"文字",@"音乐"]
    CGFloat DigitalRobotBottomTitleToolBarViewW = ScreenW;
    CGFloat DigitalRobotBottomTitleToolBarViewH = 50.0+kIPhoneBottom_Height;
    CGFloat DigitalRobotBottomTitleToolBarViewX = 0;
    CGFloat DigitalRobotBottomTitleToolBarViewY = ScreenH-DigitalRobotBottomTitleToolBarViewH;
    
    [self.bgView addSubview:self.bottomTitleToolBarBgView];
    
    self.bottomTitleToolBarBgView.frame = CGRectMake(DigitalRobotBottomTitleToolBarViewX, DigitalRobotBottomTitleToolBarViewY, DigitalRobotBottomTitleToolBarViewW, DigitalRobotBottomTitleToolBarViewH);
    self.bottomTitleToolBarBgView.backgroundColor = UIColor.blackColor;
    
    
    self.DigitalRobotBottomTitleToolBarViewArray = @[@"老板IP",@"配音",@"背景",@"文字",@"音乐"];
    self.DigitalRobotBottomTitleToolBarViewIconArray = @[@"xsTabarBossIP",@"xsTabarBossPeiYin",@"xsTabarBossBackgrand",@"xsTabarBossText",@"xsTabarBossMusic"];
    xsBossIPBottomTitleToolBarView *toolBarView = [[xsBossIPBottomTitleToolBarView alloc] initWithButtonTitles:self.DigitalRobotBottomTitleToolBarViewArray withIcons:self.DigitalRobotBottomTitleToolBarViewIconArray];
    [self.bottomTitleToolBarBgView addSubview:toolBarView];
    toolBarView.delegate = self;
    toolBarView.frame = CGRectMake(0, 0, ScreenW, 50);
    
    
    CGFloat DigitalRobotBottomBgViewW = ScreenW;
    
    CGFloat tempScreenYiBan = self.DigitalRobotBottomBgView_height;//ScreenH * 0.4;
    CGFloat DigitalRobotBottomBgViewH = tempScreenYiBan;//220;//
    CGFloat DigitalRobotBottomBgViewX = 0;
    CGFloat DigitalRobotBottomBgViewY = ScreenH-DigitalRobotBottomBgViewH-DigitalRobotBottomTitleToolBarViewH;
    
    [self.bgView addSubview:self.DigitalRobotBottomBgView];
    
    self.DigitalRobotBottomBgView.frame = CGRectMake(DigitalRobotBottomBgViewX, DigitalRobotBottomBgViewY, DigitalRobotBottomBgViewW, DigitalRobotBottomBgViewH);
    self.DigitalRobotBottomBgView.backgroundColor = UIColor.blackColor;
    
    
    XSWeakSelf;
    xsDigitalRobotBottomView *RobotBottomView = [[xsDigitalRobotBottomView alloc] init];
    [self.DigitalRobotBottomBgView addSubview:RobotBottomView];
    self.RobotBottomView = RobotBottomView;
//    RobotBottomView.xsPreviewCallbackBlock = ^(UIButton * _Nonnull sender) {
//
//        XSLogMethod
//
//        NSLog(@"预览被点击");
//    };
//    RobotBottomView.xsExportCallbackBlock = ^(UIButton * _Nonnull sender) {
//
//        XSLogMethod
//        NSLog(@"导出被点击");
//
////        dispatch_async(dispatch_get_main_queue(), ^{
////
////            UIImage *tempImg3 = [UIImage xsConvertViewRegionToImage:weakSelf.topImgBgView region:weakSelf.recordUserDragView.frame];
////
////
////            UIImageView *tempImgV3 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, tempImg3.size.width, tempImg3.size.height)];
////            tempImgV3.image = tempImg3;
////            [weakSelf.view addSubview:tempImgV3];
////
////
////            int a = 20;
////        });
//    };

    RobotBottomView.xsMaterialCallbackBlock = ^(UIButton * _Nonnull sender) {
        
        XSLogMethod
        
        NSLog(@"素材被点击");
        dispatch_async(dispatch_get_main_queue(), ^{
            
            //素材是否隐藏 YES隐藏 NO显示
            [weakSelf xsMaterialIsHiden:!sender.selected];
            
            if(sender.selected){
                //[weakSelf show_SelectAddMaterialV];
                
                
                //根据cropTg显示底部
                [weakSelf xsShowBottomEditorStatuWithCropTg:1];

                
                if(weakSelf.xsSelectAddMaterialModelMarray.count>0){
                    [weakSelf show_HadAddMaterialListV];
                    
                    //设置添加素材按钮文本
                    [weakSelf xsMaterialViewChangeAddMaterialButonTitle];
                }
                else{
                    //
                    //显示添加素材按钮
                    [weakSelf.RobotBottomView xsChangeAddMaterialLabelText:kLocalizedString(@"添加素材")];
                    [weakSelf.RobotBottomView xsChangeAddMaterialLabelLeftIcon:@"bossIPEdit_icon_add"];
                }
                
                //cropTag  0 数字人 1素材 2标题 3字幕
                [weakSelf xsHidenNotCurentRectViewWithCropTage:1 withIsHiddenAllImageAndLabel:NO];
                [weakSelf xsFindUserDragViewWithCropTage:1];
            }
            else{
                
                if(weakSelf.xsSelectAddMaterialModelMarray.count>0){
                    [weakSelf.RobotBottomView xsChangexsAddMaterialButtonHidel:NO];
                }
                else{
                    [weakSelf.RobotBottomView xsChangexsAddMaterialButtonHidel:YES];
                }
            }
        });
    };
    RobotBottomView.xsTitleCallbackBlock = ^(UIButton * _Nonnull sender) {
        
        
        XSLogMethod
        
        NSLog(@"标题被点击");
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf xsTitleIsHiden:!sender.selected];
            
            if(sender.selected){
                //cropTag  0 数字人 1素材 2标题 3字幕
                [weakSelf xsHidenNotCurentRectViewWithCropTage:2 withIsHiddenAllImageAndLabel:NO];
                [weakSelf xsFindUserDragViewWithCropTage:2];
                
                //设置xsTextView中的输入文字及placehold文字提示
                [weakSelf bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:2];
//[weakSelf show_xsTextView];
                
                [weakSelf xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_bigTitle];
            }
        });
    };
    RobotBottomView.xsSubtitlesCallbackBlock = ^(UIButton * _Nonnull sender) {
        
        XSLogMethod
        
        NSLog(@"字幕被点击");
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf xsSubtitlesIsHiden:!sender.selected];
            
            if(sender.selected){
                //cropTag  0 数字人 1素材 2标题 3字幕
                [weakSelf xsHidenNotCurentRectViewWithCropTage:3 withIsHiddenAllImageAndLabel:NO];
                [weakSelf xsFindUserDragViewWithCropTage:3];
                
                //设置xsTextView中的输入文字及placehold文字提示
                [weakSelf bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:3];
                
//[weakSelf show_xsTextView];
                [weakSelf xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_bigTitle];
            }
        });
    };
    RobotBottomView.delegate = self;
    RobotBottomView.backgroundColor = UIColor.clearColor;
    RobotBottomView.frame = CGRectMake(0, 0, DigitalRobotBottomBgViewW, DigitalRobotBottomBgViewH);
    [RobotBottomView xsChangeFrame];
}

- (NSMutableArray *)TestRobotCropViewTopLeftDeleteButtonsMarray{
    if(!_TestRobotCropViewTopLeftDeleteButtonsMarray){
        _TestRobotCropViewTopLeftDeleteButtonsMarray = [[NSMutableArray alloc] init];
    }
    return _TestRobotCropViewTopLeftDeleteButtonsMarray;
}
- (NSMutableArray *)TestRobotCropViewMarray{
    if(!_TestRobotCropViewMarray){
        _TestRobotCropViewMarray = [[NSMutableArray alloc] init];
    }
    return _TestRobotCropViewMarray;
}

- (NSMutableArray *)TestRobotCropCurrentMarray{
    if(!_TestRobotCropCurrentMarray){
        _TestRobotCropCurrentMarray = [[NSMutableArray alloc] init];
    }
    return _TestRobotCropCurrentMarray;
}

// 设置view的中心坐标
- (void)xsSetViewCenterpointWith:(xsCropBaseView *)pointView withParrentView:(UIView *)pView{
    
//    // 或者使用 convertPoint:toView: 方法
//    CGPoint centerInParentViewUsingMethod = [pointView convertPoint:pointView.center toView:pView];
    
    CGFloat widgetCenterPointX = pointView.frame.origin.x+pointView.width*0.5;
    CGFloat widgetCenterPointY = pointView.frame.origin.y+pointView.height*0.5;
    
//    NSLog(@"pointView.widgetCenterPointx=%f y==%f\n",widgetCenterPointX,widgetCenterPointY);
    
    if([pointView isKindOfClass:[xsCropBaseView class]]||
       [pointView isKindOfClass:[xsCropBaseImageView class]]||
       [pointView isKindOfClass:[xsCropBaseLabel class]]||
       [pointView isKindOfClass:[xsCropBaseButton class]]){
        pointView.widgetCenterPoint = CGPointMake(widgetCenterPointX, widgetCenterPointY);
        
        CGRect backgroundImageRect = self.bossBackgroundImage.frame;
        
        CGFloat leftX = widgetCenterPointX-backgroundImageRect.origin.x;
        pointView.widgetxBili = leftX/self.bossBackgroundImage.width;
        
//        widgetTopyBiBottomy
        CGFloat topy = widgetCenterPointY-backgroundImageRect.origin.y;
        pointView.widgetyBili = topy/self.bossBackgroundImage.height;
        
        
//        if([pointView isKindOfClass:[xsCropBaseView class]]||
//           [pointView isKindOfClass:[xsCropBaseImageView class]]||
//           [pointView isKindOfClass:[xsCropBaseLabel class]]){
//            
//            NSLog(@"pointView.widgetCenterPointx=%f y==%f\n",widgetCenterPointX,widgetCenterPointY);
//            NSLog(@"widgetxBili=%f widgetyBili==%f\n",pointView.widgetxBili,pointView.widgetyBili);
//        }
        
//        UIView *ttt = [UIView new];
//        ttt.backgroundColor = UIColor.redColor;
//        [pointView addSubview:ttt];
//        [ttt mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.width.height.mas_equalTo(12);
//            make.center.equalTo(pointView);
//        }];
    }
    
}

#pragma mark 创建图片的cropview  CropView_imageV创建UIimageView CropView_Label创建UILabel
- (void)xsTestRobotCropImageViewWithCropTag:(NSInteger)cTag withImgOrLabel:(CropImageViewOrLabelType)viewType withImageSource:(NSString *)imgSourceStr withTitle:(NSString *)titleStr withOffsetY:(CGFloat)offsety{
    
    
    xsCropBaseView *TestRobotCropV = [self xsGetCropViewWithCropTag:cTag];
    
    
    CGFloat xsCropBtnW = 25;
    CGFloat xsCropBtnH = 25;//30;
    
    xsCropBaseButton *xsCropBtn = [self xsGetTopLeftDeleteButtonWithCropTag:cTag];
   
    [self.TestRobotCropViewTopLeftDeleteButtonsMarray addObject:xsCropBtn];
    
//    CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotImageView.frame)-xsCropBtnW;
//    CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotImageView.frame);
//    xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
    
    //[self.topImgBgView addSubview:xsCropBtn];
//    [self xsHidenNotCurrenDeleteButtonWithCropTag:cTag];
//    // 设置view的中心坐标
//    [self xsSetViewCenterpointWith:xsCropBtn withParrentView:self.topImgBgView];
    
//    self.xsNumberRobot_width = loveW9*count;
//    self.xsNumberRobot_height = loveH16*count;
    
    if(viewType==CropView_imageV){
//        CGFloat xsTestRobotImageViewW = self.xsNumberRobot_width;//150;
//        CGFloat xsTestRobotImageViewH = self.xsNumberRobot_width*2.0/3.0;//210;
//        CGFloat xsTestRobotImageViewX = (self.topImgBgView.width-xsTestRobotImageViewW)*0.5;
//        CGFloat xsTestRobotImageViewY = (self.topImgBgView.height-xsTestRobotImageViewH)*0.5;
        
        CGFloat xsTestRobotImageViewW = self.bossBackgroundImage.width;//150;
        CGFloat xsTestRobotImageViewH = self.bossBackgroundImage.height;//210;
        CGFloat xsTestRobotImageViewX = (self.topImgBgView.width-xsTestRobotImageViewW)*0.5;
        CGFloat xsTestRobotImageViewY = (self.topImgBgView.height-xsTestRobotImageViewH)*0.5;
        
        if(self.xsCreateCropViewCout==1){
            
            xsTestRobotImageViewW = self.bossBackgroundImage.width;//150;
            xsTestRobotImageViewH = self.bossBackgroundImage.width*2.0/3.0;//210;
            xsTestRobotImageViewX = (self.topImgBgView.width-xsTestRobotImageViewW)*0.5;
            xsTestRobotImageViewY = (self.topImgBgView.height-xsTestRobotImageViewH)*0.5;
        }
        
        if(offsety>0){
            xsTestRobotImageViewY = offsety;
        }
        // 数字人背景
        xsCropBaseImageView *xsTestRobotImageView = [[xsCropBaseImageView alloc] initWithFrame:CGRectMake(xsTestRobotImageViewX, xsTestRobotImageViewY, xsTestRobotImageViewW, xsTestRobotImageViewH)];
        //xsTestRobotImageView.image = [UIImage imageNamed:@"bossIPDefaultImage"];
        xsTestRobotImageView.contentMode = UIViewContentModeScaleAspectFit;
       
        
        if(cTag>0){
            if(imgSourceStr!=nil||imgSourceStr.length>0){
                xsTestRobotImageView.image = [UIImage imageNamed:imgSourceStr];
            }
        }
        if(cTag==1){

            xsTestRobotImageView.image = [UIImage imageNamed:@"bossIPDefaultImage"];
        }
       
        
        
        //        if(cTag==1){
        //
        //            xsTestRobotImageView.image = [UIImage imageNamed:@"ipboosHeadIcon"];
        //        }
        xsTestRobotImageView.userInteractionEnabled = YES;
        xsTestRobotImageView.cropTag = cTag;
        [self.topImgBgView addSubview:xsTestRobotImageView];
        [self.TestRobotCropCurrentMarray addObject:xsTestRobotImageView];
        [self xsCreateOverlayViewToView:xsTestRobotImageView];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:xsTestRobotImageView withParrentView:self.topImgBgView];
        
//    CGFloat xsCropBtnW = 25;
//    CGFloat xsCropBtnH = 25;//30;
//    CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotImageView.frame)-xsCropBtnW;
//    CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotImageView.frame);
//    xsCropBaseButton *xsCropBtn = [self xsGetTopLeftDeleteButtonWithCropTag:cTag];
//    [self.topImgBgView addSubview:xsCropBtn];
//    [self.TestRobotCropViewTopLeftDeleteButtonsMarray addObject:xsCropBtn];
//    xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
//    [self xsHidenNotCurrenDeleteButtonWithCropTag:cTag];
//    // 设置view的中心坐标
//    [self xsSetViewCenterpointWith:xsCropBtn withParrentView:self.topImgBgView];
        CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotImageView.frame)-xsCropBtnW;
        CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotImageView.frame);
        xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
        
        
        //        if(cTag==0){
        //
        //            TestRobotCropV.backgroundColor = UIColor.orangeColor;
        //            TestRobotCropV.alpha = 0.35;
        //        }
        //        else{
        //            TestRobotCropV.backgroundColor = UIColor.cyanColor;
        //            TestRobotCropV.alpha = 0.35;
        //        }
        [self.topImgBgView addSubview:TestRobotCropV];
        TestRobotCropV.frame =xsTestRobotImageView.frame;
        TestRobotCropV.center = xsTestRobotImageView.center;
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:TestRobotCropV withParrentView:self.topImgBgView];
        
        
        if(self.TestRobotCropViewMarray.count==2){
            [self xsMaterialIsHiden:YES];
        }
    }
    else{
        CGFloat xsTestRobotLabelW = 150;
        CGFloat xsTestRobotLabelH = 60;
        CGFloat xsTestRobotLabelX = (self.topImgBgView.width-xsTestRobotLabelW)*0.5;
        CGFloat xsTestRobotLabelY = (self.topImgBgView.height-xsTestRobotLabelH)*0.5-60;
    
        if(offsety>0){
            xsTestRobotLabelY = offsety;
        }
        
        if(cTag==3){
            xsTestRobotLabelY=CGRectGetMaxY(self.bossBackgroundImage.frame)-xsTestRobotLabelH-25;
        }
        xsCropBaseLabel *xsTestRobotLabel = [[xsCropBaseLabel alloc] initWithFrame:CGRectMake(xsTestRobotLabelX, xsTestRobotLabelY, xsTestRobotLabelW, xsTestRobotLabelH)];
        xsTestRobotLabel.userInteractionEnabled = YES;
        xsTestRobotLabel.cropTag = cTag;
        xsTestRobotLabel.backgroundColor = UIColor.clearColor;
//        xsTestRobotLabel.font = Font(16);
//        xsTestRobotLabel.textColor = COLOR_Black;
        xsTestRobotLabel.numberOfLines = 0;
        xsTestRobotLabel.text = kLocalizedString(@"请输入标题");
        xsTestRobotLabel.recodeBaseStr = kLocalizedString(@"请输入标题");
        if(titleStr!=nil||titleStr.length>0){
            xsTestRobotLabel.text = titleStr;
        }
        
        //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
        if(cTag>3){
            xsTestRobotLabel.text = @"";
            xsTestRobotLabel.recodeBaseStr = @"";
        }
        //上次输入的文本
        xsTestRobotLabel.recodeBaseStr = @"";
        //字体类别
        xsTestRobotLabel.xsFontFamilyMd = [xsFontFamilyData new];
        //文字的背景颜色
        xsTestRobotLabel.xsFontStyleMd = [xsFontStyleData new];
        //文字颜色
        xsTestRobotLabel.xsTextColorString = @"#FFFFFF";
        //文字描边
        xsTestRobotLabel.xsTextContourColorString = @"";
        //文字大小
        xsTestRobotLabel.xsTextSizeF = 16.0;
        xsTestRobotLabel.xsFontStyleMd.outlineColour = @"";
        xsTestRobotLabel.xsFontStyleMd.primaryColour = @"#FFFFFF";
        xsTestRobotLabel.xsFontStyleMd.outlineBorderWidth = 0;
        xsTestRobotLabel.xsFontStyleMd.borderStyle = 0;
        xsTestRobotLabel.xsFontFamilyMd.fontNameLinux = @"";
        

        
        
        xsTestRobotLabel.font = Font(xsTestRobotLabel.xsTextSizeF);
        xsTestRobotLabel.textColor = [UIColor xsColorwithHexString:xsTestRobotLabel.xsFontStyleMd.primaryColour Alpha:1.0];
        
        xsTestRobotLabel.textAlignment = NSTextAlignmentCenter;
        [self.topImgBgView addSubview:xsTestRobotLabel];
        [self.TestRobotCropCurrentMarray addObject:xsTestRobotLabel];
        [self xsCreateOverlayViewToView:xsTestRobotLabel];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:xsTestRobotLabel withParrentView:self.topImgBgView];
        
        
//    CGFloat xsCropBtnW = 25;
//    CGFloat xsCropBtnH = 25;//30;
//    CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotLabel.frame)-xsCropBtnW;
//    CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotLabel.frame);
//    xsCropBaseButton *xsCropBtn = [self xsGetTopLeftDeleteButtonWithCropTag:cTag];
//    [self.topImgBgView addSubview:xsCropBtn];
//    [self.TestRobotCropViewTopLeftDeleteButtonsMarray addObject:xsCropBtn];
//    xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
//    [self xsHidenNotCurrenDeleteButtonWithCropTag:cTag];
//    // 设置view的中心坐标
//    [self xsSetViewCenterpointWith:xsCropBtn withParrentView:self.topImgBgView];
        CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotLabel.frame)-xsCropBtnW;
        CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotLabel.frame);
        xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
        
        
    
        [self.topImgBgView addSubview:TestRobotCropV];
        TestRobotCropV.frame =xsTestRobotLabel.frame;
        TestRobotCropV.center = xsTestRobotLabel.center;
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:TestRobotCropV withParrentView:self.topImgBgView];
        
        
        if(self.TestRobotCropViewMarray.count==3){
            [self xsTitleIsHiden:YES];
        }
        if(self.TestRobotCropViewMarray.count==4){
            [self xsSubtitlesIsHiden:YES];
        }
        
        [self xsTextUpdateTextFontStyleWith:xsTestRobotLabel];
    }
    
    [self.topImgBgView addSubview:xsCropBtn];
    [self xsHidenNotCurrenDeleteButtonWithCropTag:cTag];
    // 设置view的中心坐标
    [self xsSetViewCenterpointWith:xsCropBtn withParrentView:self.topImgBgView];
    
}

#pragma mark 创建每个拖动控件四周遮罩的view
- (void)xsCreateOverlayViewToView:(xsCropBaseView *)spView{
    
    
    xsBossIPOverlayView *tempTopOverlayView = [[xsBossIPOverlayView alloc] init];
    tempTopOverlayView.BossIPOverlayPosition = BossIPOverlay_top;
    [spView addSubview:tempTopOverlayView];
    tempTopOverlayView.frame = CGRectMake(0, 0, spView.width, 0);
    
    xsBossIPOverlayView *tempRightOverlayView = [[xsBossIPOverlayView alloc] init];
    tempRightOverlayView.BossIPOverlayPosition = BossIPOverlay_right;
    [spView addSubview:tempRightOverlayView];
    tempRightOverlayView.frame = CGRectMake(spView.width, 0, 0, spView.height);
    
    xsBossIPOverlayView *tempBottomOverlayView = [[xsBossIPOverlayView alloc] init];
    tempBottomOverlayView.BossIPOverlayPosition = BossIPOverlay_bottom;
    [spView addSubview:tempBottomOverlayView];
    tempBottomOverlayView.frame = CGRectMake(0, spView.height, spView.width, 0);
    
    xsBossIPOverlayView *tempLeftOverlayView = [[xsBossIPOverlayView alloc] init];
    tempLeftOverlayView.BossIPOverlayPosition = BossIPOverlay_left;
    [spView addSubview:tempLeftOverlayView];
    tempLeftOverlayView.frame = CGRectMake(0, 0, 0, spView.height);
    
    
//    tempTopOverlayView.backgroundColor = UIColor.redColor;
//    tempRightOverlayView.backgroundColor = UIColor.greenColor;
//    tempBottomOverlayView.backgroundColor = UIColor.blueColor;
//    tempLeftOverlayView.backgroundColor = UIColor.orangeColor;
    
    tempTopOverlayView.backgroundColor    = UIColor.blackColor;
    tempRightOverlayView.backgroundColor  = UIColor.blackColor;
    tempBottomOverlayView.backgroundColor = UIColor.blackColor;
    tempLeftOverlayView.backgroundColor   = UIColor.blackColor;
    
    tempTopOverlayView.hidden = YES;
    tempRightOverlayView.hidden = YES;
    tempBottomOverlayView.hidden = YES;
    tempLeftOverlayView.hidden = YES;
}

- (xsCropBaseView *)xsGetCropViewWithCropTag:(NSInteger)cTag{
    CGRect frame = CGRectMake(0, 0, self.minCropWidth, self.minCropHeight);
    xsCropBaseView *TestRobotCropV = [[xsCropBaseView alloc] initWithFrame:frame];
    TestRobotCropV.userInteractionEnabled = true;
    UIPanGestureRecognizer *cropViewtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotTranslation:)];
    [TestRobotCropV addGestureRecognizer: cropViewtp];
    TestRobotCropV.cropTag = cTag;
    [self.TestRobotCropViewMarray addObject:TestRobotCropV];
          
    
    UIColor *tempLineViewColor = COLOR_HEX(0x6FE64B);//UIColor.whiteColor;
    
    UITapGestureRecognizer *tapCropViewEvent = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapTestRobotCropVAction:)];
    [TestRobotCropV addGestureRecognizer:tapCropViewEvent];
    
    xsCropBaseImageView * leftTopImage = [[xsCropBaseImageView alloc] initWithImage:[UIImage imageNamed:@"corner_left_top"]];
    leftTopImage.frame = CGRectMake(0, 0, 20, 20);
    [leftTopImage setAutoresizingMask: UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleRightMargin];
    leftTopImage.tag = leftTop;
    leftTopImage.userInteractionEnabled = true;
    UIPanGestureRecognizer *leftToptp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [leftTopImage addGestureRecognizer: leftToptp];
    [TestRobotCropV addSubview:leftTopImage];
    leftTopImage.cropTag = cTag;
    
    
    
    xsCropBaseImageView * rightTopImage = [[xsCropBaseImageView alloc] initWithImage:[UIImage imageNamed:@"corner_right_top"]];
    rightTopImage.frame = CGRectMake(CGRectGetMaxX(frame)-20, 0, 20, 20);
    [rightTopImage setAutoresizingMask: UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin];
    rightTopImage.tag = rightTop;
    rightTopImage.userInteractionEnabled = true;
    UIPanGestureRecognizer *rightToptp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [rightTopImage addGestureRecognizer: rightToptp];
    [TestRobotCropV addSubview:rightTopImage];
    rightTopImage.cropTag = cTag;
    
    
    
    
    xsCropBaseImageView * leftBottomImage = [[xsCropBaseImageView alloc] initWithImage:[UIImage imageNamed:@"corner_left_bottom"]];
    leftBottomImage.frame = CGRectMake(0, CGRectGetMaxY(frame)-20, 20, 20);
    [leftBottomImage setAutoresizingMask: UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleRightMargin];
    leftBottomImage.tag = leftBottom;
    leftBottomImage.userInteractionEnabled = true;
    UIPanGestureRecognizer *leftBottomtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [leftBottomImage addGestureRecognizer: leftBottomtp];
    [TestRobotCropV addSubview:leftBottomImage];
    leftBottomImage.cropTag = cTag;
    
    
    
    xsCropBaseImageView * rightBottomImage = [[xsCropBaseImageView alloc] initWithImage:[UIImage imageNamed:@"corner_right_bottom"]];
    rightBottomImage.frame = CGRectMake(CGRectGetMaxX(frame)-20, CGRectGetMaxY(frame)-20, 20, 20);
    [rightBottomImage setAutoresizingMask: UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin];
    rightBottomImage.tag = rightBottom;
    rightBottomImage.userInteractionEnabled = true;
    UIPanGestureRecognizer *rightBottomtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [rightBottomImage addGestureRecognizer: rightBottomtp];
    [TestRobotCropV addSubview:rightBottomImage];
    rightBottomImage.cropTag = cTag;
    
    
    
    xsCropBaseView * topView = [[xsCropBaseView alloc] init];
    topView.frame = CGRectMake(20, 0, frame.size.width-20*2, 20);
    [topView setAutoresizingMask: UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin];
    topView.tag = top;
    topView.userInteractionEnabled = true;
    UIPanGestureRecognizer *topViewtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [topView addGestureRecognizer: topViewtp];
    [TestRobotCropV addSubview:topView];
    topView.cropTag = cTag;
    //topView.backgroundColor = COLOR_HEX(0x526DDF);
    xsCropBaseView * topViewLine = [[xsCropBaseView alloc] init];
    topViewLine.frame = CGRectMake(0, 0, topView.width, 2.0);
    [topViewLine setAutoresizingMask: UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin];
    [topView addSubview:topViewLine];
    topViewLine.backgroundColor = tempLineViewColor;//COLOR_HEX(0x526DDF);
    
    
    xsCropBaseView * bottomView = [[xsCropBaseView alloc] init];
    bottomView.frame = CGRectMake(20, frame.size.height-20, frame.size.width-20*2, 20);
    [bottomView setAutoresizingMask: UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
    bottomView.tag = bottom;
    bottomView.userInteractionEnabled = true;
    UIPanGestureRecognizer *bottomViewtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [bottomView addGestureRecognizer: bottomViewtp];
    [TestRobotCropV addSubview:bottomView];
    bottomView.cropTag = cTag;
    //bottomView.backgroundColor = COLOR_HEX(0x526DDF);
    xsCropBaseView * bottomViewLine = [[xsCropBaseView alloc] init];
    bottomViewLine.frame = CGRectMake(0, bottomView.height-2.0, bottomView.width, 2.0);
    [bottomViewLine setAutoresizingMask: UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
    [bottomView addSubview:bottomViewLine];
    bottomViewLine.backgroundColor = tempLineViewColor;//COLOR_HEX(0x526DDF);
    
    
    xsCropBaseView * leftView = [[xsCropBaseView alloc] init];
    leftView.frame = CGRectMake(0, 20, 20, frame.size.height-20*2);
    [leftView setAutoresizingMask: UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleRightMargin];
    leftView.tag = left;
    leftView.userInteractionEnabled = true;
    UIPanGestureRecognizer *leftViewtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [leftView addGestureRecognizer: leftViewtp];
    [TestRobotCropV addSubview:leftView];
    leftView.cropTag = cTag;
    //leftView.backgroundColor = COLOR_HEX(0x526DDF);
    xsCropBaseView * leftViewLine = [[xsCropBaseView alloc] init];
    leftViewLine.frame = CGRectMake(0, 0, 2.0, leftView.height);
    [leftViewLine setAutoresizingMask: UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleRightMargin];
    [leftView addSubview:leftViewLine];
    leftViewLine.backgroundColor = tempLineViewColor;//COLOR_HEX(0x526DDF);
    
    
    
    xsCropBaseView * rightView = [[xsCropBaseView alloc] init];
    rightView.frame = CGRectMake(frame.size.width-20, 20, 20, frame.size.height-20*2);
    [rightView setAutoresizingMask: UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleLeftMargin];
    rightView.tag = right;
    rightView.userInteractionEnabled = true;
    UIPanGestureRecognizer *rightViewtp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(xsTestRobotMove:)];
    [rightView addGestureRecognizer: rightViewtp];
    [TestRobotCropV addSubview:rightView];
    rightView.cropTag = cTag;
    //rightView.backgroundColor = COLOR_HEX(0x526DDF);
    xsCropBaseView * rightViewLine = [[xsCropBaseView alloc] init];
    rightViewLine.frame = CGRectMake(rightView.width-2.0, 0, 2.0, rightView.height);
    [rightViewLine setAutoresizingMask: UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleLeftMargin];
    [rightView addSubview:rightViewLine];
    rightViewLine.backgroundColor = tempLineViewColor;//COLOR_HEX(0x526DDF);
    
    
    
    
    UIColor *CenterLineViewColor = UIColor.whiteColor;
    UIView *topViewCenterLineView = [[UIView alloc] init];
    topViewCenterLineView.backgroundColor = CenterLineViewColor;
    [topView addSubview:topViewCenterLineView];
    [topViewCenterLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView.mas_centerX);
        make.top.equalTo(topView.mas_top).offset(-2);
        make.width.mas_equalTo(20.0);
        make.height.mas_equalTo(6.0);
    }];
    //topViewCenterLineView.userInteractionEnabled = NO;
    
    UIView *bottomCenterLineView = [[UIView alloc] init];
    bottomCenterLineView.backgroundColor = CenterLineViewColor;
    [bottomView addSubview:bottomCenterLineView];
    [bottomCenterLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bottomView.mas_centerX);
        make.bottom.equalTo(bottomView.mas_bottom).offset(2);
        make.width.mas_equalTo(20.0);
        make.height.mas_equalTo(6.0);
    }];
    //bottomCenterLineView.userInteractionEnabled = NO;
    
    UIView *leftCenterLineView = [[UIView alloc] init];
    leftCenterLineView.backgroundColor = CenterLineViewColor;
    [leftView addSubview:leftCenterLineView];
    [leftCenterLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(leftView.mas_centerY);
        make.left.equalTo(leftView.mas_left).offset(-2);
        make.width.mas_equalTo(6.0);
        make.height.mas_equalTo(20.0);
    }];
    //leftCenterLineView.userInteractionEnabled = NO;
    
    UIView *rightCenterLineView = [[UIView alloc] init];
    rightCenterLineView.backgroundColor = CenterLineViewColor;
    [rightView addSubview:rightCenterLineView];
    [rightCenterLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(rightView.mas_centerY);
        make.right.equalTo(rightView.mas_right).offset(2);
        make.width.mas_equalTo(6.0);
        make.height.mas_equalTo(20.0);
    }];
    //rightCenterLineView.userInteractionEnabled = NO;
    
    topViewCenterLineView.layer.cornerRadius = 3.1;
    topViewCenterLineView.layer.masksToBounds = YES;
    
    bottomCenterLineView.layer.cornerRadius = 3.1;
    bottomCenterLineView.layer.masksToBounds = YES;
    
    leftCenterLineView.layer.cornerRadius = 3.1;
    leftCenterLineView.layer.masksToBounds = YES;
    
    rightCenterLineView.layer.cornerRadius = 3.1;
    rightCenterLineView.layer.masksToBounds = YES;
    
    
    
    CGFloat CircleViewWH = 14.0;
    UIView *leftTopCircleView = [[UIView alloc] init];
    leftTopCircleView.backgroundColor = CenterLineViewColor;
    [leftTopImage addSubview:leftTopCircleView];
    [leftTopCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leftTopImage.mas_top).offset(-3);
        make.left.equalTo(leftTopImage.mas_left).offset(-3);
        make.width.mas_equalTo(CircleViewWH);
        make.height.mas_equalTo(CircleViewWH);
    }];
    //leftTopCircleView.userInteractionEnabled = NO;
    
    UIView *leftBottomCircleView = [[UIView alloc] init];
    leftBottomCircleView.backgroundColor = CenterLineViewColor;
    [leftBottomImage addSubview:leftBottomCircleView];
    [leftBottomCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(leftBottomImage.mas_bottom).offset(3);
        make.left.equalTo(leftBottomImage.mas_left).offset(-3);
        make.width.mas_equalTo(CircleViewWH);
        make.height.mas_equalTo(CircleViewWH);
    }];
    //leftTopCircleView.userInteractionEnabled = NO;
    
    UIView *rightTopCircleViewCircleView = [[UIView alloc] init];
    rightTopCircleViewCircleView.backgroundColor = CenterLineViewColor;
    [rightTopImage addSubview:rightTopCircleViewCircleView];
    [rightTopCircleViewCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(rightTopImage.mas_top).offset(-3);
        make.right.equalTo(rightTopImage.mas_right).offset(3);
        make.width.mas_equalTo(CircleViewWH);
        make.height.mas_equalTo(CircleViewWH);
    }];
    //rightTopCircleViewCircleView.userInteractionEnabled = NO;
    
    UIView *rightBottomCircleViewCircleView = [[UIView alloc] init];
    rightBottomCircleViewCircleView.backgroundColor = CenterLineViewColor;
    [rightBottomImage addSubview:rightBottomCircleViewCircleView];
    [rightBottomCircleViewCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(rightBottomImage.mas_bottom).offset(3);
        make.right.equalTo(rightBottomImage.mas_right).offset(3);
        make.width.mas_equalTo(CircleViewWH);
        make.height.mas_equalTo(CircleViewWH);
    }];
    //rightBottomCircleViewCircleView.userInteractionEnabled = NO;
    
    leftTopCircleView.layer.cornerRadius = 7.1;
    leftTopCircleView.layer.masksToBounds = YES;
    
    leftBottomCircleView.layer.cornerRadius = 7.1;
    leftBottomCircleView.layer.masksToBounds = YES;
    
    rightTopCircleViewCircleView.layer.cornerRadius = 7.1;
    rightTopCircleViewCircleView.layer.masksToBounds = YES;
    
    rightBottomCircleViewCircleView.layer.cornerRadius = 7.1;
    rightBottomCircleViewCircleView.layer.masksToBounds = YES;
    
    return  TestRobotCropV;
}
- (void)TapTestRobotCropVAction:(UIPanGestureRecognizer *)pan{
    
    xsCropBaseView *panView = (xsCropBaseView *)pan.view;
    if(!panView){
        return;
    }
    
//    // ReferView 参照的view
//    UIView *ReferView = self.topImgBgView;// self.digitalManImageView
    
    //CGPoint point = [pan locationInView:ReferView];
    
    
    xsCropBaseView *tempCropView;
    for (xsCropBaseView *cropViewItem in self.TestRobotCropViewMarray) {
        if(cropViewItem.cropTag==panView.cropTag){
            tempCropView = cropViewItem;
            break;
        }
    }
    if(!tempCropView){
        return;
    }
    
    
    
    xsCropBaseView *changeImageFrameView;
    for (xsCropBaseView *cropViewFrameItem in self.TestRobotCropCurrentMarray) {
        if(cropViewFrameItem.cropTag==panView.cropTag){
            changeImageFrameView = cropViewFrameItem;
            break;
        }
    }
    if(!changeImageFrameView){
        return;
    }
    [self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
    [self xsFindUserDragViewWithCropTage:panView.cropTag];
    
    [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
    
    NSLog(@"xsTestRobotMove-cropTag==%ld\n",(long)panView.cropTag);
    
    //设置xsTextView中的输入文字及placehold文字提示
    [self bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:panView.cropTag];
    
    //根据cropTg显示底部
    [self xsShowBottomEditorStatuWithCropTg:panView.cropTag];
    
    
    NSInteger tempCurrentLeve = [UIView indexOfView:panView inSuperView:self.topImgBgView];
    
    NSLog(@"tempCurrentLeve-tempCurrentLeve==%ld\n",tempCurrentLeve);
    
    // 设置view的中心坐标
    [self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
    // 设置view的中心坐标
    [self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
    
    
    //根据cropTg显示底部
    [self xsShowBottomEditorStatuWithCropTg:panView.cropTag];
}

#pragma mark 设置xsTextView中的输入文字及placehold文字提示
- (void)bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:(NSInteger)cropTagInt{
    NSLog(@"bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith--cropTagInt==%ld\n",cropTagInt);
    // 查找选中的label并给输入框设置值
    if(_xsTextView){
        BOOL isFindLabel = NO;
        for(xsCropBaseLabel *tempCropItemLabel in self.TestRobotCropCurrentMarray){
            if([tempCropItemLabel isKindOfClass:[xsCropBaseLabel class]]){
                if(tempCropItemLabel.cropTag==cropTagInt){
                    
                    //cropTag 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
                    NSString *tempRecodeBaseStr = tempCropItemLabel.recodeBaseStr;
                    
                    bossTopTextPlaceholdType tempTextPlaceholdType = TopTextPlaceholdType_text;
                    if(kStringIsEmpty(tempRecodeBaseStr)){
                        if(cropTagInt==2){//标题
                            tempRecodeBaseStr = @"请输入标题";
                            tempTextPlaceholdType = TopTextPlaceholdType_tile;
                        }
                        else if(cropTagInt==3){//字幕
                            tempRecodeBaseStr = @"请输入视频文案(10~800字)";
                            tempTextPlaceholdType = TopTextPlaceholdType_Subtitles;
                        }
                        else{
                            tempRecodeBaseStr = @"请输入文本(0~50字)";
                            tempTextPlaceholdType = TopTextPlaceholdType_text;
                        }
                        
                        [_xsTextView xsTopInputTextFeildTextString:@""];
                        [_xsTextView bossChangeTopInputTextFeildPlaceholderWithbossTopTextPlaceholdType:tempTextPlaceholdType];
                        
                    }
                    else{
                        [_xsTextView xsTopInputTextFeildTextString:tempRecodeBaseStr];
                    }
                    
                    isFindLabel = YES;
                    break;
                }
            }
        }
////    *TestRobotCropViewMarray;// 0数字人  1素材 2标题 3字幕
////    *TestRobotCropCurrentMarray;//  0数字人  1素材 2标题 3字幕
//if(!isFindLabel){
//    //            [_xsTextView xsTextViewChangeTextString:@""];
//
//    if(_xsTextBgView){
//        if(self.xsTextBgView.xsIsShow)
//        {
//            [self hide_xsTextView];
//            [_xsTextView xstopInputTextFeildresignFirstRespond];
//        }
//        else{
//
//        }
//    }
//
//}
//else{
//    if(!self.xsTextBgView.xsIsShow){
//        [self show_xsTextView];
//        //[_xsTextView xsTopInputTextFeildTextString:@""];
//    }
//}
        
        
//        if(cropTagInt>0){
//            if(cropTagInt==3){
//                [_xsTextView bossChangeTopInputTextFeildPlaceholderWithbossTopTextPlaceholdType:TopTextPlaceholdType_Subtitles];
//            }
//            else{
//                [_xsTextView bossChangeTopInputTextFeildPlaceholderWithbossTopTextPlaceholdType:TopTextPlaceholdType_text];
//            }
//        }
    }
}


#pragma mark 修改左上角删除按钮的位置
- (void)xsChangeTopLeftDeleteButtonViewFrameWith:(xsCropBaseView *)findCropBaseButtonFrameV{
    
    xsCropBaseButton *findCropBaseButtonFrameView;
    for (xsCropBaseButton *tempDeleteButtonFrameItem in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
        if(tempDeleteButtonFrameItem.cropTag==findCropBaseButtonFrameV.cropTag){
            findCropBaseButtonFrameView = tempDeleteButtonFrameItem;
            break;
        }
    }
    if(findCropBaseButtonFrameView){
        
        CGFloat xsCropBtnW = 25;
        CGFloat xsCropBtnH = 25;//30;
        CGFloat xsCropBtnX = CGRectGetMinX(findCropBaseButtonFrameV.frame)-xsCropBtnW*0.5;//-xsCropBtnW-4;
        CGFloat xsCropBtnY = CGRectGetMinY(findCropBaseButtonFrameV.frame)-xsCropBtnH*0.5;//-10;
        findCropBaseButtonFrameView.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:findCropBaseButtonFrameView withParrentView:self.topImgBgView];
        
        [self xsHidenNotCurrenDeleteButtonWithCropTag:findCropBaseButtonFrameView.cropTag];
        
    }
}
#pragma mark 创建拖动视图左上角删除按钮
-(xsCropBaseButton *)xsGetTopLeftDeleteButtonWithCropTag:(NSInteger)cropTagInt{
    
    xsCropBaseButton *xsCropDeleteBut = [xsCropBaseButton buttonWithType:UIButtonTypeCustom];
    xsCropDeleteBut.backgroundColor = UIColor.clearColor;
    xsCropDeleteBut.cropTag = cropTagInt;
    [xsCropDeleteBut setImage:[UIImage imageNamed:@"xsBossIPTopLeftDeleteImg"] forState:UIControlStateNormal];
    [xsCropDeleteBut addTarget:self action:@selector(xsCropDeleteButEvent:) forControlEvents:UIControlEventTouchUpInside];
    
    return xsCropDeleteBut;
}
- (void)xsCropDeleteButEvent:(xsCropBaseButton *)sender{
    
    NSLog(@"xsCropDeleteButEvent--sender.cropTag==%ld",sender.cropTag);
    if(sender.cropTag>3){
        
//        @property (nonatomic,strong)NSMutableArray *TestRobotCropViewTopLeftDeleteButtonsMarray;
//        //TestRobotCropViewMarray记录的是拖动的四个角和四条边  cropTag 0 素材 1数字人 2标题 3字幕
//        @property (nonatomic,strong)NSMutableArray *TestRobotCropViewMarray;
//        //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕
//        @property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
//        // 记录点击页面上的控件 可能是 xsCropBaseLabel xsCropBaseImageView这两个
//        @property (nonatomic,weak) UIView *recordUserDragView;//
//        
//        CGFloat cropLabelY = robitItemViewY+30;
//        CGFloat robitItemViewY = (self.topImgBgView.height-self.xsNumberRobot_height)*0.5;
//        
//        
//        隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
//        查找当前被选中的label或者imageview
        
        xsCropBaseView *tempFindDeleteBaseV;
        for (xsCropBaseView *tempBaseV in self.TestRobotCropViewMarray) {
            if(tempBaseV.cropTag == sender.cropTag){
                tempFindDeleteBaseV = tempBaseV;
                break;
            }
        }
        [self.TestRobotCropViewMarray removeObject:tempFindDeleteBaseV];
        tempFindDeleteBaseV.hidden = YES;
        [tempFindDeleteBaseV removeFromSuperview];
        
        
        xsCropBaseView *tempFindCurrentDeleteBaseV;
        for (xsCropBaseView *tempCurrentDeleteBaseV in self.TestRobotCropCurrentMarray) {
            if(tempCurrentDeleteBaseV.cropTag == sender.cropTag){
                tempFindCurrentDeleteBaseV = tempCurrentDeleteBaseV;
                break;
            }
        }
        [self.TestRobotCropCurrentMarray removeObject:tempFindCurrentDeleteBaseV];
        tempFindCurrentDeleteBaseV.hidden = YES;
        [tempFindCurrentDeleteBaseV removeFromSuperview];
        
        
        
        
        xsCropBaseView *tempFindDbutton;
        for (xsCropBaseView *tempDbutton in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
            if(tempDbutton.cropTag == sender.cropTag){
                tempFindDbutton = tempDbutton;
                break;
            }
        }
        [self.TestRobotCropViewTopLeftDeleteButtonsMarray removeObject:tempFindDbutton];
        tempFindDbutton.hidden = YES;
        [tempFindDbutton removeFromSuperview];
        
        
        xsCropBaseView *tempShowBaseV = self.TestRobotCropCurrentMarray.lastObject;
        
//        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
//        [self xsHidenNotCurentRectViewWithCropTage:tempShowBaseV.cropTag withIsHiddenAllImageAndLabel:YES];
        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
        [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
        
        //查找当前被选中的label或者imageview
        [self xsFindUserDragViewWithCropTage:tempShowBaseV.cropTag];
        
        [self hide_xsTextView];
        [self.xsTextView xstopInputTextFeildresignFirstRespond];
       
    }
}




#pragma mark 拖动框选的方框时触发
- (void)xsTestRobotTranslation:(UIPanGestureRecognizer *)pan{
    
    
    NSLog(@"xsTestRobotTranslation--000000");
    
    xsCropBaseView *panView = (xsCropBaseView *)pan.view;
    if(!panView){
        return;
    }
    
    xsCropBaseView *tempCropView;
    for (xsCropBaseView *cropViewItem in self.TestRobotCropViewMarray) {
        if(cropViewItem.cropTag==panView.cropTag){
            tempCropView = cropViewItem;
            break;
        }
    }
    if(!tempCropView){
        return;
    }
    
    
    
    xsCropBaseView *changeImageFrameView;
    for (xsCropBaseView *cropViewFrameItem in self.TestRobotCropCurrentMarray) {
        if(cropViewFrameItem.cropTag==panView.cropTag){
            changeImageFrameView = cropViewFrameItem;
            break;
        }
    }
    if(!changeImageFrameView){
        return;
    }
    
//[self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
//[self xsFindUserDragViewWithCropTage:panView.cropTag];
    
    //NSLog(@"xsTestRobotTranslation-cropTag==%ld\n",(long)panView.cropTag);
    
    // ReferView 参照的view
    UIView *ReferView = self.topImgBgView;//self.digitalManImageView;//
    //digitalManImageView
    CGPoint point = [pan locationInView:ReferView];
    if(point.x<0){
        point.x = 0;
    }
    if(point.x>ReferView.frame.size.width){
        point.x = ReferView.frame.size.width;
    }
    if(point.y<0){
        point.y = 0;
    }
    if(point.y > ReferView.frame.size.height){
        point.y = ReferView.frame.size.height;
    }
    
    if(pan.state == UIGestureRecognizerStateChanged){
        
        CGRect frame = tempCropView.frame;
        CGFloat minX = 0.0;
        CGFloat minY = 0.0;
        CGFloat maxX = 0.0;//ReferView.frame.size.width-frame.size.width;
        CGFloat maxY = 0.0;//ReferView.frame.size.height-frame.size.height;
        CGFloat x = point.x-frame.size.width/2;
        
        minX = self.bossBackgroundImage.origin.x- panView.width*0.5+11.5;
        maxX = self.bossBackgroundImage.origin.x+self.bossBackgroundImage.width-panView.width*0.5-11.5;
        
        minY = self.bossBackgroundImage.origin.y-panView.height*0.5;
        maxY = self.bossBackgroundImage.origin.y+self.bossBackgroundImage.height-panView.height*0.5;
if (x < minX) {
    x = minX;
}
if (x > maxX) {
    x = maxX;
}
        CGFloat y = point.y-frame.size.height/2;
if (y < minY) {
    y = minY;
}
if (y > maxY) {
    y = maxY;
}
        frame.origin.x = x;
        frame.origin.y = y;
        tempCropView.frame = frame;
        //        resetCropMask();
        [self resetCropMask];
        
        //        self.digitalManImageView.frame = CGRectMake(x, y, frame.size.width, frame.size.height);
        //self.digitalManImageView.frame = self.cropView.frame;
        changeImageFrameView.frame = tempCropView.frame;
        
        
//[self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
//// 设置view的中心坐标
//[self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
//// 设置view的中心坐标
//[self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
        [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
        
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
    }
    else if(pan.state == UIGestureRecognizerStateEnded||pan.state == UIGestureRecognizerStateBegan){
        NSLog(@"xsTestRobotTranslation--UIGestureRecognizerStateEnded");
        
        
        [self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
        [self xsFindUserDragViewWithCropTage:panView.cropTag];
        
        [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
        
        //根据cropTg显示底部
        [self xsShowBottomEditorStatuWithCropTg:panView.cropTag];
    }
    [self changeBossIPOverlayViewFrameAndHiddenstateWithView:changeImageFrameView];
}

- (void)xsTestRobotMove:(UIPanGestureRecognizer *)pan
{
    
    
    xsCropBaseView *panView = (xsCropBaseView *)pan.view;
    if(!panView){
        return;
    }
    
    
    NSLog(@"xsTestRobotMove--111111111");
//    NSLog(@"xsTestRobotMove-cropTag==%ld\n",(long)panView.cropTag);
//    NSLog(@"xsTestRobotMove-tag==%ld\n",(long)panView.tag);
    
    // ReferView 参照的view
    UIView *ReferView = self.topImgBgView;// self.digitalManImageView
    
    CGPoint point = [pan locationInView:ReferView];
    
    
    xsCropBaseView *tempCropView;
    for (xsCropBaseView *cropViewItem in self.TestRobotCropViewMarray) {
        if(cropViewItem.cropTag==panView.cropTag){
            tempCropView = cropViewItem;
            break;
        }
    }
    if(!tempCropView){
        return;
    }
    
    
    
    xsCropBaseView *changeImageFrameView;
    for (xsCropBaseView *cropViewFrameItem in self.TestRobotCropCurrentMarray) {
        if(cropViewFrameItem.cropTag==panView.cropTag){
            changeImageFrameView = cropViewFrameItem;
            break;
        }
    }
    if(!changeImageFrameView){
        return;
    }
//[self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
//[self xsFindUserDragViewWithCropTage:panView.cropTag];
    
    //NSLog(@"xsTestRobotMove-cropTag==%ld\n",(long)panView.cropTag);
    
    if(point.x<0){
        point.x = 0;
    }
    if(point.x>ReferView.frame.size.width){
        point.x = ReferView.frame.size.width;
    }
    if(point.y<0){
        point.y = 0;
    }
    if(point.y > ReferView.frame.size.height){
        point.y = ReferView.frame.size.height;
    }
    
    //NSLog(@"xsmove--point==%@\n",NSStringFromCGPoint(point));
    
    if(pan.state == UIGestureRecognizerStateChanged){
        
        CGFloat itemMinHeight11_5 = 11.5;
        
        if (panView.tag == leftTop) {
            
            
            CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
          
//if(x>(tempViewCenterX-itemMinHeight11_5)){
//    x = tempViewCenterX-itemMinHeight11_5;
//}
//if(x<self.bossBackgroundImage.origin.x){
//    x = self.bossBackgroundImage.origin.x;
//}
            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
            
            
            
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
        
            CGFloat tempMaxY = tempViewCenterY-itemMinHeight11_5;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<self.bossBackgroundImage.origin.y){
//    y = self.bossBackgroundImage.origin.y;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;
            
           
//            frame = CGRectMake(x, y, tempVW, tempVH);
//            tempCropView.frame = frame;
            
            
            if(tempVW<itemMinHeight11_5*2.0){
                frame = CGRectMake(tempCropView.frame.origin.x, tempCropView.frame.origin.y, itemMinHeight11_5*2.0, tempCropView.frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            
            if((tempCropView.widgetCenterPoint.y-point.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            
            
            [self resetCropMask];
            
            
            
        } else if (panView.tag == left ){

            CGRect frame = tempCropView.frame;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
           
            
//if(x>(tempViewCenterX-itemMinHeight11_5)){
//    x = tempViewCenterX-itemMinHeight11_5;
//}
//if(x<self.bossBackgroundImage.origin.x){
//    x = self.bossBackgroundImage.origin.x;
//}

            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
//frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
//tempCropView.frame = frame;

            if(tempVW<itemMinHeight11_5*2.0){
                frame = CGRectMake(tempCropView.frame.origin.x, tempCropView.frame.origin.y, itemMinHeight11_5*2.0, tempCropView.frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            [self resetCropMask];
            
            
        } else if (panView.tag == leftBottom) {
            
            
            CGRect frame = tempCropView.frame;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
         
//if(x>(tempViewCenterX-itemMinHeight11_5)){
//    x = tempViewCenterX-itemMinHeight11_5;
//}
//if(x<self.bossBackgroundImage.origin.x){
//    x = self.bossBackgroundImage.origin.x;
//}
            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
            
            
            //CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
           
            CGFloat tempMaxY = self.bossBackgroundImage.origin.y+self.bossBackgroundImage.height;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<(tempViewCenterY+itemMinHeight11_5)){
//    y = tempViewCenterY+itemMinHeight11_5;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;
            
            
//            frame = CGRectMake(x, y, tempVW, tempVH);
//            tempCropView.frame = frame;
            
            if(tempVW<itemMinHeight11_5*2.0){
                frame = CGRectMake(tempCropView.frame.origin.x, tempCropView.frame.origin.y, itemMinHeight11_5*2.0, tempCropView.frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            if((point.y-tempCropView.widgetCenterPoint.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            [self resetCropMask];
            
        } else if (panView.tag == top) {
            
            
            CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
         
            CGFloat tempMaxY = tempViewCenterY-itemMinHeight11_5;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<self.bossBackgroundImage.origin.y){
//    y = self.bossBackgroundImage.origin.y;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;

           
//frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
//tempCropView.frame = frame;
            
            
            if((tempCropView.widgetCenterPoint.y-point.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            
            
            
            
            [self resetCropMask];
            
        } else if (panView.tag == rightTop) {
            
            CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
        
            CGFloat tempMaxY = tempViewCenterY-itemMinHeight11_5;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<self.bossBackgroundImage.origin.y){
//    y = self.bossBackgroundImage.origin.y;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;
            
            
            
            //CGRect frame = tempCropView.frame;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
         
            CGFloat tempMaxX = self.bossBackgroundImage.origin.x+self.bossBackgroundImage.width;
//if(x>tempMaxX){
//    x = tempMaxX;
//}
//if(x<(tempViewCenterX+itemMinHeight11_5)){
//    x = tempViewCenterX+itemMinHeight11_5;
//}
            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
            
//            frame = CGRectMake(x, y, tempVW, tempVH);
//            tempCropView.frame = frame;
            
            
            if((x-itemMinHeight11_5)<(tempCropView.widgetCenterPoint.x)){
                frame = CGRectMake(tempCropView.widgetCenterPoint.x-itemMinHeight11_5, frame.origin.y, itemMinHeight11_5*2.0, frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            
            if((tempCropView.widgetCenterPoint.y-point.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            
            
            [self resetCropMask];
            
        } else if (panView.tag == right) {
            
            CGRect frame = tempCropView.frame;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
         
            CGFloat tempMaxX = self.bossBackgroundImage.origin.x+self.bossBackgroundImage.width;
//if(x>tempMaxX){
//    x = tempMaxX;
//}
//if(x<(tempViewCenterX+itemMinHeight11_5)){
//    x = tempViewCenterX+itemMinHeight11_5;
//}
            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
//frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
//tempCropView.frame = frame;
           

            
//            NSLog(@"tempCropView.widgetCenterPoint.x==%f\n",tempCropView.widgetCenterPoint.x);
//            NSLog(@"x==%f\n",x);
            if((x-itemMinHeight11_5)<(tempCropView.widgetCenterPoint.x)){
                frame = CGRectMake(tempCropView.widgetCenterPoint.x-itemMinHeight11_5, frame.origin.y, itemMinHeight11_5*2.0, frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            [self resetCropMask];
            
        } else if (panView.tag == rightBottom) {
            
            CGRect frame = tempCropView.frame;
            CGFloat x = point.x;
            
           CGFloat tempViewCenterX = tempCropView.widgetxBili*self.bossBackgroundImage.width+self.bossBackgroundImage.origin.x;
          
            CGFloat tempMaxX = self.bossBackgroundImage.origin.x+self.bossBackgroundImage.width;
//if(x>tempMaxX){
//    x = tempMaxX;
//}
//if(x<(tempViewCenterX+itemMinHeight11_5)){
//    x = tempViewCenterX+itemMinHeight11_5;
//}
            
            CGFloat tempVW = (tempViewCenterX-x)*2.0;
            
            
            //CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
           
            CGFloat tempMaxY = self.bossBackgroundImage.origin.y+self.bossBackgroundImage.height;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<(tempViewCenterY+itemMinHeight11_5)){
//    y = tempViewCenterY+itemMinHeight11_5;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;
            
            
//            frame = CGRectMake(x, y, tempVW, tempVH);
//            tempCropView.frame = frame;
            
            if((x-itemMinHeight11_5)<(tempCropView.widgetCenterPoint.x)){
                frame = CGRectMake(tempCropView.widgetCenterPoint.x-itemMinHeight11_5, frame.origin.y, itemMinHeight11_5*2.0, frame.size.height);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(x, frame.origin.y, tempVW, frame.size.height);
                tempCropView.frame = frame;
            }
            
            if((point.y-tempCropView.widgetCenterPoint.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            
            [self resetCropMask];
            
        } else if (panView.tag == bottom) {
            
            CGRect frame = tempCropView.frame;
            CGFloat y = point.y;
            
           CGFloat tempViewCenterY = tempCropView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
        
            CGFloat tempMaxY = self.bossBackgroundImage.origin.y+self.bossBackgroundImage.height;
//if(y>tempMaxY){
//    y = tempMaxY;
//}
//if(y<(tempViewCenterY+itemMinHeight11_5)){
//    y = tempViewCenterY+itemMinHeight11_5;
//}
            
            CGFloat tempVH = (tempViewCenterY-y)*2.0;

//
//frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
//tempCropView.frame = frame;
            
            NSLog(@"tempCropView.widgetCenterPoint.y==%f\n",tempCropView.widgetCenterPoint.y);
            NSLog(@"point.y==%f\n",point.y);
            
            if((point.y-tempCropView.widgetCenterPoint.y)<itemMinHeight11_5){
                frame = CGRectMake(frame.origin.x,tempCropView.widgetCenterPoint.y-itemMinHeight11_5, frame.size.width, itemMinHeight11_5*2.0);
                tempCropView.frame = frame;
            }
            else{
                frame = CGRectMake(frame.origin.x, y, frame.size.width, tempVH);
                tempCropView.frame = frame;
            }
            
            [self resetCropMask];
        }
        
        
        changeImageFrameView.frame = tempCropView.frame;
        
        [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
    }
    else if(pan.state == UIGestureRecognizerStateEnded){//||pan.state == UIGestureRecognizerStateBegan
        NSLog(@"xsTestRobotMove--UIGestureRecognizerStateEnded");
        
        [self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
        [self xsFindUserDragViewWithCropTage:panView.cropTag];
        
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
        // 设置view的中心坐标
        [self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];

        [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
    }
    
    
//    [self xsHidenNotCurentRectViewWithCropTage:panView.cropTag withIsHiddenAllImageAndLabel:NO];
//    [self xsFindUserDragViewWithCropTage:panView.cropTag];
//    
//    // 设置view的中心坐标
//    [self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
//    // 设置view的中心坐标
//    [self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
//
//    [self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
    
    
//changeImageFrameView.frame = tempCropView.frame;
    
//// 设置view的中心坐标
//[self xsSetViewCenterpointWith:tempCropView withParrentView:self.topImgBgView];
//// 设置view的中心坐标
//[self xsSetViewCenterpointWith:changeImageFrameView withParrentView:self.topImgBgView];
//
//[self xsChangeTopLeftDeleteButtonViewFrameWith:changeImageFrameView];
    
    [self changeBossIPOverlayViewFrameAndHiddenstateWithView:changeImageFrameView];
}


- (void)changeBossIPOverlayViewFrameAndHiddenstateWithView:(xsCropBaseView *)cgFramgeView{
    
    
    //CGFloat tempViewCenterY = cgFramgeView.widgetyBili*self.bossBackgroundImage.height+self.bossBackgroundImage.origin.y;
    
    CGFloat minX = self.bossBackgroundImage.origin.x;
    CGFloat minY = self.bossBackgroundImage.origin.y;
    
    CGFloat maxX = self.bossBackgroundImage.origin.x+self.bossBackgroundImage.width;
    CGFloat maxY = self.bossBackgroundImage.origin.y+self.bossBackgroundImage.height;
    
    CGFloat moveViewMinX = cgFramgeView.origin.x;
    CGFloat moveViewMinY = cgFramgeView.origin.y;
    
    xsBossIPOverlayView *topView;
    xsBossIPOverlayView *rightView;
    xsBossIPOverlayView *bottomView;
    xsBossIPOverlayView *leftView;
    for (xsBossIPOverlayView *tempOverlayView in cgFramgeView.subviews) {
        if([tempOverlayView isKindOfClass:[xsBossIPOverlayView class]]){
            if(tempOverlayView.BossIPOverlayPosition==BossIPOverlay_top){
                topView = tempOverlayView;
            }
            else if(tempOverlayView.BossIPOverlayPosition==BossIPOverlay_right){
                rightView = tempOverlayView;
            }
            else if(tempOverlayView.BossIPOverlayPosition==BossIPOverlay_bottom){
                bottomView = tempOverlayView;
            }
            else if(tempOverlayView.BossIPOverlayPosition==BossIPOverlay_left){
                leftView = tempOverlayView;
            }
        }
    }
    
    CGFloat moveViewMaxX = cgFramgeView.origin.x+cgFramgeView.width;
    CGFloat moveViewMaxY = cgFramgeView.origin.y+cgFramgeView.height;
    
    
    BOOL isImageView = NO;
    BOOL isMirror = NO;
    if([cgFramgeView isKindOfClass:[xsCropBaseImageView class]]){
        isImageView = YES;
        
        xsCropBaseImageView *tempCropImgV = (xsCropBaseImageView *)cgFramgeView;
        isMirror = tempCropImgV.isMirrorImage;
    }
    
    if(isImageView&&isMirror){
        
        if(moveViewMaxX>maxX){
            // 显示右边遮罩的view
            leftView.hidden = NO;
            
            CGFloat W = cgFramgeView.origin.x+cgFramgeView.width-maxX;
            CGFloat H = cgFramgeView.height;
            CGFloat Y = 0;
            CGFloat X = 0;
            leftView.frame = CGRectMake(X, Y, W, H);
        }
        else{
            
            // 隐藏右边遮罩的view
            leftView.hidden = YES;
            
        }
    }
    else{
        if(moveViewMinX<minX){
            // 显示左边遮罩的view
            leftView.hidden = NO;
            
            CGFloat H = cgFramgeView.height;
            CGFloat X = 0;
            CGFloat Y = 0;
            CGFloat W = minX-cgFramgeView.origin.x;
            leftView.frame = CGRectMake(X, Y, W, H);
            
        }
        else{
            // 隐藏左边遮罩的view
            leftView.hidden = YES;
        }
    }
    
    
    
    if(moveViewMinY<minY){
        // 显示上边遮罩的view
        topView.hidden = NO;
        
        CGFloat H = minY-leftView.origin.y;
        CGFloat X = 0;
        CGFloat Y = 0;
        CGFloat W = cgFramgeView.width;
        topView.frame = CGRectMake(X, Y, W, H);
    }
    else{
        // 隐藏上边遮罩的view
        topView.hidden = YES;
    }
    
    
    
   
    if(isImageView&&isMirror){
        
        if(moveViewMinX<minX){
            // 显示左边遮罩的view
            rightView.hidden = NO;
            
            CGFloat W = minX-cgFramgeView.origin.x;
            CGFloat X = cgFramgeView.width-W;
            CGFloat H = cgFramgeView.height;
            CGFloat Y = 0;
            
            rightView.frame = CGRectMake(X, Y, W, H);
        }
        else{
            
            // 隐藏左边遮罩的view
            rightView.hidden = YES;
        }
    }
    else{
        if(moveViewMaxX>maxX){
            // 显示右边遮罩的view
            rightView.hidden = NO;
            
            CGFloat W = cgFramgeView.origin.x+cgFramgeView.width-maxX;
            CGFloat H = cgFramgeView.height;
            CGFloat Y = 0;
            CGFloat X = cgFramgeView.width-W;
            rightView.frame = CGRectMake(X, Y, W, H);
        }
        else{
            // 隐藏右边遮罩的view
            rightView.hidden = YES;
            
        }
    }
    
    
    if(moveViewMaxY>maxY){
        // 显示底边遮罩的view
        bottomView.hidden = NO;
        
        
        CGFloat X = 0;
        CGFloat H = cgFramgeView.origin.y+cgFramgeView.height-maxY;
        CGFloat W = cgFramgeView.width;
        CGFloat Y = cgFramgeView.height-H;
        
        bottomView.frame = CGRectMake(X, Y, W, H);
        
    }
    else{
        // 隐藏底边遮罩的view
        bottomView.hidden = YES;
        
    }
    
}

#pragma mark 隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
- (void)xsHidenNotCurentRectViewWithCropTage:(NSInteger)cTag withIsHiddenAllImageAndLabel:(BOOL)isHiddenAll{
    
    
    if(!isHiddenAll){
        for (xsCropBaseView *tempBaseView in self.TestRobotCropViewMarray) {
            if(tempBaseView.cropTag!=cTag){
                for (UIView *tempHidView in tempBaseView.subviews) {
                    if([tempHidView isKindOfClass:[xsCropBaseImageView class]]||
                       [tempHidView isKindOfClass:[xsCropBaseView class]]){
                        tempHidView.hidden = YES;
                    }
                }
            }
            else{
                
                for (UIView *tempHidView in tempBaseView.subviews) {
                    if([tempHidView isKindOfClass:[xsCropBaseImageView class]]||
                       [tempHidView isKindOfClass:[xsCropBaseView class]]){
                        tempHidView.hidden = NO;
                    }
                }
            }
        }
    }
    else{
        [self xsHidenAllRectViewWithCrop];
    }
}
#pragma mark 隐藏全部view的四个角和四条边的view(label和imgview)
- (void)xsHidenAllRectViewWithCrop{
    for (xsCropBaseView *tempBaseView in self.TestRobotCropViewMarray) {
        for (UIView *tempHidView in tempBaseView.subviews) {
            if([tempHidView isKindOfClass:[xsCropBaseImageView class]]||
               [tempHidView isKindOfClass:[xsCropBaseView class]]){
                tempHidView.hidden = YES;
            }
        }
    }
    
//    [self xsHidenNotCurrenDeleteButtonWithCropTag:0 withIsHiddenAllDeleteButton:YES];
    //隐藏全部左上角删除按钮
    [self xsHiddenAllTopLeftDeleteButton];
}
#pragma mark 查找当前被选中的label或者imageview 没有找到就默认选中最后一项
- (void)xsFindUserDragViewWithCropTage:(NSInteger)cTag{
    
    BOOL isFind = NO;
    for (xsCropBaseView *tempBaseView in self.TestRobotCropCurrentMarray) {
        if(tempBaseView.cropTag==cTag){
            self.recordUserDragView = tempBaseView;
            isFind = YES;
            break;
        }
    }
    if(!isFind){
        if(self.TestRobotCropCurrentMarray.count>0){
            self.recordUserDragView = self.TestRobotCropCurrentMarray.lastObject;
        }
    }
}

#pragma mark 绘制拖动后框外阴影
- (void)resetCropMask{


//    NSLog(@"resetCropMask");
//    UIBezierPath *path =[UIBezierPath bezierPathWithRect:self.digitalManImageView.bounds];
//    UIBezierPath *clearPath =[UIBezierPath bezierPathWithRect:self.cropView.frame];
//    [path appendPath:clearPath];
//
//    CAShapeLayer *layer =[[CAShapeLayer alloc] init];
//
//    layer.frame = self.digitalManImageView.bounds;
//    layer.fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
//    layer.strokeColor = UIColor.clearColor.CGColor;
//    layer.fillRule = kCAFillRuleEvenOdd;
//    layer.path = path.CGPath;
//
//
//    for (CALayer *item in self.digitalManImageView.layer.sublayers) {
//        if([item isKindOfClass:[CAShapeLayer class]]){
//            [item removeFromSuperlayer];
//        }
//    }
//    [self.digitalManImageView.layer addSublayer:layer];
}

#pragma mark 保存拖动框选的切图
- (void)cropClicked:(id)sender{
    
//    let frame = cropView.frame
//    if let image = digitalManImageView.image {
//        let scale = image.size.width/screenWidth
//        let cropImage = image.cropping(to: CGRect(x: frame.origin.x*scale, y: frame.origin.y*scale, width: frame.width*scale, height: frame.height*scale))
//        imageArray.insert(cropImage, at: 0)
//        collectionView.reloadData()
//    }
//    NSLog(@"cropClicked--sender==%@",sender);
//    CGRect frame = self.cropView.frame;
    
}


#pragma mark 素材是否隐藏 YES隐藏 NO显示
- (void)xsMaterialIsHiden:(BOOL)hideState{
    
//    *TestRobotCropViewMarray;// 0数字人  1素材 2标题 3字幕
//    *TestRobotCropCurrentMarray;//  0数字人  1素材 2标题 3字幕
    
    for(xsCropBaseView *tempCropItem in self.TestRobotCropViewMarray){
        if(tempCropItem.cropTag==1){
            tempCropItem.hidden = hideState;
        }
    }
    for(xsCropBaseView *tempCropItem in self.TestRobotCropCurrentMarray){
        if(tempCropItem.cropTag==1){
            tempCropItem.hidden = hideState;
        }
    }
    
}
#pragma mark 标题是否隐藏 YES隐藏 NO显示
- (void)xsTitleIsHiden:(BOOL)hideState{
    for(xsCropBaseView *tempCropItem in self.TestRobotCropViewMarray){
        if(tempCropItem.cropTag==2){
            tempCropItem.hidden = hideState;
        }
    }
    for(xsCropBaseView *tempCropItem in self.TestRobotCropCurrentMarray){
        if(tempCropItem.cropTag==2){
            tempCropItem.hidden = hideState;
        }
    }
}
#pragma mark 字幕是否隐藏 YES隐藏 NO显示
- (void)xsSubtitlesIsHiden:(BOOL)hideState{
    for(xsCropBaseView *tempCropItem in self.TestRobotCropViewMarray){
        if(tempCropItem.cropTag==3){
            tempCropItem.hidden = hideState;
        }
    }
    for(xsCropBaseView *tempCropItem in self.TestRobotCropCurrentMarray){
        if(tempCropItem.cropTag==3){
            tempCropItem.hidden = hideState;
        }
    }
}

#pragma mark xsDigitalRobotBottomViewProtoCol
#pragma mark 视频文案发生改变
- (void)DigitalRobotBottomViewCopywritingTextViewTextChange:(NSString *)textChangeString{
    
    NSString *tempStr = [NSString stringWithFormat:@"DigitalRobotBottomViewCopywritingTextViewTextChange--textChangeString==%@",textChangeString];
    XSLogMethod2(tempStr)
    
//    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
//        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
//        tempLabel.text = textChangeString;
//    }
//    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
//        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
////        tempCropImageView.image = [];
//    }
}
- (void)DigitalRobotBottomViewMyVoiceButtonEvent:(UIButton *)sender{
    
    NSString *tempStr = [NSString stringWithFormat:@"DigitalRobotBottomViewMyVoiceButtonEvent--sender==%@",sender];
    XSLogMethod2(tempStr)
    
    [self show_xsCongfgonfigurationMusicView];
}

// 我的素材列表被点击
- (void)DigitalRobotBottomViewAddMaterialButtonEvent:(UIButton *)sender{
    NSString *tempStr = [NSString stringWithFormat:@"DigitalRobotBottomViewAddMaterialButtonEvent--sender==%@",sender];
    XSLogMethod2(tempStr)
    
    [self show_HadAddMaterialListV];
    
    //// CropTage 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:1 withIsHiddenAllImageAndLabel:NO];
}

// 覆盖输入视频文案的button被点击
- (void)xsInputCopywritingButtonButtonEvent:(UIButton *)sender{
    
    NSLog(@"xsInputCopywritingButtonButtonEvent");
    
    NSString *tempString = [_RobotBottomView xsGetInputCopywritingText];
    if(kStringIsEmpty(tempString)){
        tempString = [NSString new];
    }
    
    // typeStatu 2 图片 3视频
    //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
    // action 2004 跳转到视频字幕
    // action 2005 预览 导出
//[self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2004",@"bossCopywritingText":tempString}} domChanges:nil];
}

// 智能划词button被点击
- (void)xsZhiNengHuaCiButtonEvent:(UIButton *)sender{
    
    if(sender.selected){
        
        self.xsNumberRobot_smartHighlightingEnabled = @"1";//  ":@"",// 是否开启智能划重点 0 关闭 1 开启
    }
    else{
        self.xsNumberRobot_smartHighlightingEnabled = @"0";//  ":@"",// 是否开启智能划重点 0 关闭 1 开启
    }
    
}



#pragma mark -
#pragma mark 机器人图片 素材 标题 字幕 文字等被点击时显示 start ⭐️⭐️⭐️⭐️⭐️
// 编辑大标题 小标题 背景图片 数字机器人图片
- (void)xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:(xsEditeDigitalRobotType)sType{
    
//    xsEditeDigitalRobot_bigTitle,// 大标题                  --->对应    编辑 样式 气泡 动画 层级
//    xsEditeDigitalRobot_smallTitle,// 小标题                --->对应    样式 气泡 动画 层级
//    xsEditeDigitalRobot_backgroundImg, // 背景图像                  --->对应    层级 镜像 删除
//    xsEditeDigitalRobot_digitalRobotImg // 机器人图像        --->对应    更换形象  层级 镜像 删除

    
    NSLog(@"xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType--sType==%lu\n",(unsigned long)sType);
//return;
    
    
    CGFloat bottomTitleToolBarBgViewW = ScreenW;
    CGFloat bottomTitleToolBarBgViewH = self.bottomTitleToolBarBgView_height;//55.0+kIPhoneBottom_Height;
    CGFloat bottomTitleToolBarBgViewX = 0;
    CGFloat bottomTitleToolBarBgViewY = ScreenH-bottomTitleToolBarBgViewH;
    if(!self.xsEditeDigitalRobotTitleVBgView){
        
        
        UIView *xsEditeDigitalRobotTitleVBgView = [[UIView alloc] init];
        [self.bgView addSubview:xsEditeDigitalRobotTitleVBgView];
        self.xsEditeDigitalRobotTitleVBgView = xsEditeDigitalRobotTitleVBgView;
        
        self.xsEditeDigitalRobotTitleVBgView.frame = CGRectMake(bottomTitleToolBarBgViewX, bottomTitleToolBarBgViewY, bottomTitleToolBarBgViewW, bottomTitleToolBarBgViewH);
self.xsEditeDigitalRobotTitleVBgView.backgroundColor = UIColor.blackColor;
        
        
        xsEditeDigitalRobotTitleView *EditeDigitalRobotTitleV = [[xsEditeDigitalRobotTitleView alloc] initWithEditeType:xsEditeDigitalRobot_digitalRobotImg];
        [self.xsEditeDigitalRobotTitleVBgView addSubview:EditeDigitalRobotTitleV];
        self.EditeDigitalRobotTitleV = EditeDigitalRobotTitleV;
        EditeDigitalRobotTitleV.frame = CGRectMake(0, 0, ScreenW, 55.0);
        EditeDigitalRobotTitleV.delegate = self;
        [self.EditeDigitalRobotTitleV xsChangeFrame];
        [self.EditeDigitalRobotTitleV showViewWithType:sType];
        self.xsEditeDigitalRobotTitleVBgView.hidden = NO;
    }
    else{
        
        if(self.xsEditeDigitalRobotTitleVBgView.hidden==YES){
            self.xsEditeDigitalRobotTitleVBgView.frame = CGRectMake(bottomTitleToolBarBgViewX, bottomTitleToolBarBgViewY, bottomTitleToolBarBgViewW, bottomTitleToolBarBgViewH);
            
            self.xsEditeDigitalRobotTitleVBgView.hidden = NO;
        }
//        else{
//            
//        }
        
        [self.EditeDigitalRobotTitleV showViewWithType:sType];
    }
    
   
}

- (void)xsHiddenEdite_Big_Small_Bgimg_DigitalRobotAction{
    CGFloat bottomTitleToolBarBgViewW = ScreenW;
    CGFloat bottomTitleToolBarBgViewH = 55.0+kIPhoneBottom_Height;
    CGFloat bottomTitleToolBarBgViewX = bottomTitleToolBarBgViewW;
    CGFloat bottomTitleToolBarBgViewY = ScreenH-bottomTitleToolBarBgViewH;
    
    self.xsEditeDigitalRobotTitleVBgView.frame = CGRectMake(bottomTitleToolBarBgViewX, bottomTitleToolBarBgViewY, bottomTitleToolBarBgViewW, bottomTitleToolBarBgViewH);
    
    self.xsEditeDigitalRobotTitleVBgView.hidden = YES;
}
#pragma mark xsEditeDigitalRobotTitleViewProtoCol
// 返回按钮被点击
- (void)xsEditeDigitalRobotTitleViewBackButtonEvent:(UIButton *)sender{
    
    NSLog(@"xsEditeDigitalRobotTitleViewBackButtonEvent");
    [self xsHiddenEdite_Big_Small_Bgimg_DigitalRobotAction];
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
}


// 按钮被点击
- (void)xsEditeDigitalRobotTitleViewItemButtonEventWithEditeType:(xsEditeDigitalRobotType)EditeTyp withSelectIndex:(NSInteger)itemIndex{
    
    NSLog(@"xsEditeDigitalRobotTitleViewItemButtonEventWithEditeType-EditeTyp==%lu",(unsigned long)EditeTyp);
    NSLog(@"xsEditeDigitalRobotTitleViewItemButtonEventWithEditeType-itemIndex==%ld",itemIndex);
    
//    气泡 动画
    //xsEditeDigitalRobot_bigTitle,// 大标题                  --->对应    编辑 样式 层级
    //xsEditeDigitalRobot_smallTitle,// 小标题                --->对应    样式 气泡 动画 层级
    //xsEditeDigitalRobot_backgroundImg, // 背景图像                  --->对应    层级 镜像 删除
    //xsEditeDigitalRobot_digitalRobotImg // 机器人图像        --->对应    更换形象  层级 镜像 删除
    if(EditeTyp==xsEditeDigitalRobot_bigTitle){
        //编辑 样式 气泡 动画 层级
        if(itemIndex==0){
            //编辑
            [self show_xsTextView];
            [_xsTextView xsChangeKeyBordStyleLineViewLocationWithTag:0];
            [_xsTextView xsTopInputTextFeildTextbecomeFirstResponder];
        }
        else if(itemIndex==1){
            //样式
            //编辑
            [self show_xsTextView];
            [_xsTextView xsChangeKeyBordStyleLineViewLocationWithTag:1];
            [_xsTextView xstopInputTextFeildresignFirstRespond];
        }
//        else if(itemIndex==2){
//            //气泡
//        }
//        else if(itemIndex==3){
//            //动画
//        }
        else if(itemIndex==2){
            self.isToBigView = YES;
            //层级
            [self xsSelectLevelWith:EditeTyp withItemIndex:itemIndex];
        }
    }
    else if(EditeTyp==xsEditeDigitalRobot_smallTitle){
        //样式 气泡 动画 层级
        if(itemIndex==0){

        }
        else if(itemIndex==1){

        }
        else if(itemIndex==2){

        }
        else if(itemIndex==3){
            self.isToBigView = YES;
            //层级
            [self xsSelectLevelWith:EditeTyp withItemIndex:itemIndex];
        }
    }
    else if(EditeTyp==xsEditeDigitalRobot_backgroundImg){// 素材

        //层级 镜像 删除
        if(itemIndex==0){
            self.isToBigView = YES;
            //层级
            [self xsSelectLevelWith:EditeTyp withItemIndex:itemIndex];
        }
        else if(itemIndex==1){
            //镜像
            if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
                xsCropBaseImageView *tempImageView = (xsCropBaseImageView *)self.recordUserDragView;
                tempImageView.isMirrorImage = !tempImageView.isMirrorImage;
                
                int xInt = 1;
                if(tempImageView.isMirrorImage){
                    xInt = -1;
                }
//                
                // 左右镜像 -1向右镜像  1左镜像
                tempImageView.transform = CGAffineTransformMakeScale(xInt, 1.0);
                
                [self changeBossIPOverlayViewFrameAndHiddenstateWithView:tempImageView];
            }
        }
        else if(itemIndex==2){
            //删除
            
            [self xsHiddenEdite_Big_Small_Bgimg_DigitalRobotAction];
            //隐藏全部view的四个角和四条边的view(label和imgview)
            [self xsHidenAllRectViewWithCrop];
            //素材是否隐藏 YES隐藏 NO显示
            [self xsMaterialIsHiden:YES];
            if(self.xsSelectAddMaterialModelMarray.count>0){
                [self.xsSelectAddMaterialModelMarray removeAllObjects];
                [self.RobotBottomView xsChangexsAddMaterialButtonHidel:YES];
                [self.RobotBottomView xsChangeMaterialButtonIsClick:NO];
                
                // 设置添加素材里面的数据全部未选中
                // 设置 全部 图片  视频collectionview的数据全部修改为为选中
                [_xsSelectAddMaterialV xsUpdateAllImageVideoModelToNotSelect];
                
                // 清空已选中素材列表
                NSArray *tempDataArr = [NSArray arrayWithArray:self.xsSelectAddMaterialModelMarray];
                [self.HadAddMaterialListV xsReloadCollectionViewWithDataArray:tempDataArr];
                
                
                [self xsMaterialViewChangeMaterialWithImage:[UIImage imageNamed:@"bossIPDefaultImage"]];
                //显示添加素材按钮
                [self.RobotBottomView xsChangeAddMaterialLabelText:kLocalizedString(@"添加素材")];
                [self.RobotBottomView xsChangeAddMaterialLabelLeftIcon:@"bossIPEdit_icon_add"];
            }
            
//            if(self.xsSelectAddMaterialModelMarray.count>0){
//                [self.RobotBottomView xsChangexsAddMaterialButtonHidel:NO];
//            }
//            else{
//                [self.RobotBottomView xsChangexsAddMaterialButtonHidel:YES];
//            }

            
        }

    }
    // // 机器人图像
    else if(EditeTyp==xsEditeDigitalRobot_digitalRobotImg){//xsEditeDigitalRobot_digitalRobotImg

        //更换形象  层级 镜像 删除
        if(itemIndex==0){
            [self xsHiddenEdite_Big_Small_Bgimg_DigitalRobotAction];
            
            //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
            [self xsShowBootmPanelWithCropTg:0];
        }
        else if(itemIndex==1){//层级
            self.isToBigView = YES;
            //层级
            [self xsSelectLevelWith:EditeTyp withItemIndex:itemIndex];
        }
        else if(itemIndex==2){
            //镜像
            if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
                xsCropBaseImageView *tempImageView = (xsCropBaseImageView *)self.recordUserDragView;
                tempImageView.isMirrorImage = !tempImageView.isMirrorImage;
                
                int xInt = 1;
                if(tempImageView.isMirrorImage){
                    xInt = -1;
                }
                

                
                // 左右镜像 -1向右镜像  1左镜像
                tempImageView.transform = CGAffineTransformMakeScale(xInt, 1.0);
                
                [self changeBossIPOverlayViewFrameAndHiddenstateWithView:tempImageView];
      
            }
        }
        else if(itemIndex==3){
            //删除
            
            [self xsHiddenEdite_Big_Small_Bgimg_DigitalRobotAction];
            
            //删除机器人
            //数字人id
            self.xsNumberRobot_digitalHumanId= 0;
            [self xsChangeDigitalRobotWithImage:[UIImage new] withDigitalHumanId:0 withDigitalHumanIdImageUrl:[NSString new]];
            
            //隐藏全部view的四个角和四条边的view(label和imgview)
            [self xsHidenAllRectViewWithCrop];
            
            if(self.xsNumberRobot_digitalHumanModel){
                
                [_DigitalRobotView xsUpdateAllDataNotSelectWithCategoryId:self.xsNumberRobot_digitalHumanModel.categoryId];
            }
        }
    }
    
}
#pragma mark 点击了层级
- (void)xsSelectLevelWith:(xsEditeDigitalRobotType)RobotType withItemIndex:(NSInteger)itemIdex{
    
    // xsShowLevelView
    
    [self show_BossIPChangeLevelVWithType:RobotType];
    [self bsShowDigitalRobotToBig:self.isToBigView];
    
}
#pragma mark 数字人大小改变时修改遮罩view的显示和隐藏
- (void)bsShowDigitalRobotToBig:(BOOL)isBig{
    
    if(isBig){
        self.topImgBgView.frame = self.topImgBgViewBigRect;
        self.bossBackgroundImage.frame = self.bossBackgroundImageBigRect;
        
        for (UIView *tempView in self.bossBackgroundImageZheZhaoMarr) {
            tempView.hidden = YES;
        }
        
        self.DigitalRobotBottomBgView.hidden = YES;
        self.topNavBarView.hidden = YES;
    }
    else{
        
        self.topImgBgView.frame = self.topImgBgViewSmalRect;
        self.bossBackgroundImage.frame = self.bossBackgroundImageSmalRect;
        
        for (UIView *tempView in self.bossBackgroundImageZheZhaoMarr) {
            tempView.hidden = NO;
        }
        
        self.DigitalRobotBottomBgView.hidden = NO;
        self.topNavBarView.hidden = NO;
    }
    
    
//self.topImgBgView.backgroundColor = UIColor.redColor;
//self.bossBackgroundImage.backgroundColor = UIColor.orangeColor;
    
    [self xsChangeAllRecordFrameIsToBig:isBig];
    
}
#pragma mark 修改被放大后的所有子view
- (void)xsChangeAllRecordFrameIsToBig:(BOOL)is2Big{
    NSLog(@"xsChangeAllRecordFrameIsToBig");
//return;
    
    
//    CGFloat topImgBgVBigW = self.topImgBgViewBigRect.size.width;
//    CGFloat topImgBgVSmallW = self.topImgBgViewSmalRect.size.height;
    
    CGFloat BgVBigW = self.bossBackgroundImageBigRect.size.width;//386.10000000000304
    //CGFloat BgVBigH = self.bossBackgroundImageBigRect.size.height;//686.40000000000543
    
    CGFloat BgVSmallW = self.bossBackgroundImageSmalRect.size.width;//279
    //CGFloat BgVSmallH = self.bossBackgroundImageSmalRect.size.height;//496
    
    //CGFloat bigAfterBigX = (BgVBigW-BgVSmallW)*0.5;
    
    CGFloat bossBackgroundWScan = BgVBigW/BgVSmallW;//1.5200000000000082  1.3838709677419463
    //CGFloat bossBackgroundHScan = bossBackgroundBgVBigH/bossBackgroundSmallH;//1.5200000000000082
    
    if(is2Big){
        for (xsCropBaseView *tempView in self.TestRobotCropViewMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
 
                
                    CGFloat oldW = tempView.width;
                    CGFloat oldH = tempView.height;
                    //(x = 207, y = 250)
                    CGFloat bigww = oldW * bossBackgroundWScan;//386.10000000000304
                    CGFloat bighh = oldH * bossBackgroundWScan;//686.40000000000532
                
                   CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
                   CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;

                CGFloat xsNewX = pointCenterX - bigww * 0.5;
                CGFloat xsNewY = pointCenterY - bighh * 0.5;//
                tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                
            }
        }
        for (xsCropBaseView *tempView in self.TestRobotCropCurrentMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
                
                
                CGFloat oldW = tempView.width;
                CGFloat oldH = tempView.height;
                //(x = 207, y = 250)
                CGFloat bigww = oldW * bossBackgroundWScan;//386.10000000000304
                CGFloat bighh = oldH * bossBackgroundWScan;//686.40000000000532
            
               CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
               CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;

            CGFloat xsNewX = pointCenterX - bigww * 0.5;
            CGFloat xsNewY = pointCenterY - bighh * 0.5;//
            tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                
                [self changeBossIPOverlayViewFrameAndHiddenstateWithView:tempView];
            }
        }
        
        for (xsCropBaseView *tempView in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
                
                
                CGFloat oldW = tempView.width;
                CGFloat oldH = tempView.height;
                //(x = 207, y = 250)
                CGFloat bigww = oldW * bossBackgroundWScan;//386.10000000000304
                CGFloat bighh = oldH * bossBackgroundWScan;//686.40000000000532
            
               CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
               CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;

            CGFloat xsNewX = pointCenterX - bigww * 0.5;
            CGFloat xsNewY = pointCenterY - bighh * 0.5;//
            tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                
            }
        }
    }
    else{
        
      
        for (xsCropBaseView *tempView in self.TestRobotCropViewMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
                
   
                
                
                CGFloat oldW = tempView.width;
                CGFloat oldH = tempView.height;
                
                CGFloat bigww = oldW / bossBackgroundWScan;
                CGFloat bighh = oldH / bossBackgroundWScan;
                
//                tempView.widgetCenterPoint = CGPointMake(tempView.widgetCenterPoint.x/bossBackgroundWScan, tempView.widgetCenterPoint.y/bossBackgroundWScan);
                
                CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
                CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;
                
                CGFloat xsNewX = pointCenterX - bigww * 0.5;
                CGFloat xsNewY = pointCenterY - bighh * 0.5;
            
                
                tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                
            }
        }
        for (xsCropBaseView *tempView in self.TestRobotCropCurrentMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
                
   
                
                
                CGFloat oldW = tempView.width;
                CGFloat oldH = tempView.height;
                
                CGFloat bigww = oldW / bossBackgroundWScan;
                CGFloat bighh = oldH / bossBackgroundWScan;
                
//                tempView.widgetCenterPoint = CGPointMake(tempView.widgetCenterPoint.x/bossBackgroundWScan, tempView.widgetCenterPoint.y/bossBackgroundWScan);
                
                CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
                CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;
                
                CGFloat xsNewX = pointCenterX - bigww * 0.5;
                CGFloat xsNewY = pointCenterY - bighh * 0.5;
            
                
                tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                [self changeBossIPOverlayViewFrameAndHiddenstateWithView:tempView];
            }
        }
        
        
        for (xsCropBaseView *tempView in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
            if([tempView isKindOfClass:[xsCropBaseView class]]||
               [tempView isKindOfClass:[xsCropBaseImageView class]]||
               [tempView isKindOfClass:[xsCropBaseLabel class]]||
               [tempView isKindOfClass:[xsCropBaseButton class]]){
                
   
                
                
                CGFloat oldW = tempView.width;
                CGFloat oldH = tempView.height;
                
                CGFloat bigww = oldW / bossBackgroundWScan;
                CGFloat bighh = oldH / bossBackgroundWScan;
                
//                tempView.widgetCenterPoint = CGPointMake(tempView.widgetCenterPoint.x/bossBackgroundWScan, tempView.widgetCenterPoint.y/bossBackgroundWScan);
                
                CGFloat pointCenterX = self.bossBackgroundImage.width*tempView.widgetxBili+self.bossBackgroundImage.origin.x;
                CGFloat pointCenterY = self.bossBackgroundImage.height*tempView.widgetyBili+self.bossBackgroundImage.origin.y;
                
                CGFloat xsNewX = pointCenterX - bigww * 0.5;
                CGFloat xsNewY = pointCenterY - bighh * 0.5;
            
                
                tempView.frame = CGRectMake(xsNewX, xsNewY, bigww, bighh);
                
            }
        }
    }
}

//// 显示层级的view
//- (void)xsShowLevelViewWith:(xsEditeDigitalRobotType)RobotType withItemIndex:(NSInteger)itemIdex{
//    
//    
//}

#pragma mark 机器人图片 素材 标题 字幕 文字等被点击时显示 end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -



- (UIView *)topImgBgView{
    if(!_topImgBgView){
        _topImgBgView = [[UIView alloc] init];
        _topImgBgView.backgroundColor = UIColor.blackColor;
    }
    return _topImgBgView;
}

- (UIView *)bgView{
    if(!_bgView){
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = UIColor.blackColor;
    }
    return _bgView;
}

- (UIScrollView *)xsUnderneathBgScrollView
{
    if(!_xsUnderneathBgScrollView){
        _xsUnderneathBgScrollView = [[UIScrollView alloc] init];
        _xsUnderneathBgScrollView.backgroundColor = UIColor.blackColor;
        _xsUnderneathBgScrollView.showsVerticalScrollIndicator = NO;
        _xsUnderneathBgScrollView.showsHorizontalScrollIndicator = NO;
    }
    return _xsUnderneathBgScrollView;
}


- (UIView *)bottomTitleToolBarBgView{
    if(!_bottomTitleToolBarBgView){
        _bottomTitleToolBarBgView = [[UIView alloc] init];
        _bottomTitleToolBarBgView.backgroundColor = UIColor.whiteColor;
    }
    return _bottomTitleToolBarBgView;
}


- (UIView *)DigitalRobotBottomBgView{
    if(!_DigitalRobotBottomBgView){
        _DigitalRobotBottomBgView = [[UIView alloc] init];
        _DigitalRobotBottomBgView.backgroundColor = UIColor.whiteColor;
    }
    return _DigitalRobotBottomBgView;
}
#pragma mark 老板IP 配音 背景 文字 选择背景音乐 被点击
#pragma mark  xsBossIPBottomTitleToolBarViewProtoCol点击底部按钮☆☆☆☆☆☆☆☆☆
- (void)xsDigitalRobotButtonBeClick:(UIButton *)button{
    
    
    NSLog(@"xsDigitalRobotButtonBeClick--button.tag==%ld\n",button.tag);
    
//    self.DigitalRobotBottomTitleToolBarViewArray = @[@"老板IP",@"配音",@"背景",@"文字",@"音乐"];
    if(button.tag==0){// 老板IP
        
         //老板IP
        [self show_xsDigitalRobotBossIPViewBgView];
        
        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
        [self xsHidenNotCurentRectViewWithCropTage:0 withIsHiddenAllImageAndLabel:NO];
    }
    else if(button.tag==1){//配音
        
        [self show_xsCongfgonfigurationMusicView];
    }
    else if(button.tag==2){//背景
        
        [self show_xsBackgroundView];
    }
    else if(button.tag==3){//文字
        [self show_xsTextView];
    }
    else if(button.tag==4){//选择背景音乐
        [self show_BossIPBackgroundView];
    }
    
    
//    else if(button.tag==5){//贴图
//        [self show_xsChartletView];
//    }
//    else if(button.tag==6){//模板
//        [self show_xsTemplateViewView];
//    }
//    else if(button.tag==7){//包装
//        
//    }
}
#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 老板IP 对应的视图
//显示点击老板IP 对应的视图
- (void)show_xsDigitalRobotBossIPViewBgView{
    
    
    CGFloat digitalRobotViewBgViewW = ScreenW;
    CGFloat digitalRobotViewBgViewH = 400.0+kIPhoneBottom_Height;
    CGFloat digitalRobotViewBgViewX = 0;
    CGFloat digitalRobotViewBgViewY = ScreenH;//-digitalRobotViewBgViewH;
    CGFloat digitalRobotViewBgViewY2 = ScreenH-digitalRobotViewBgViewH;
    
    if(!_digitalRobotViewBgView){
        [self.bgView addSubview:self.digitalRobotViewBgView];
    }
    
    if(!_DigitalRobotView){
        [self.digitalRobotViewBgView addSubview:self.DigitalRobotView];
    }
    
    self.digitalRobotViewBgView.xsIsShow = YES;
    
    self.digitalRobotViewBgView.hidden = NO;
    //[self.bgView addSubview:self.digitalRobotViewBgView];
    self.digitalRobotViewBgView.frame = CGRectMake(digitalRobotViewBgViewX, digitalRobotViewBgViewY, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
    
    self.DigitalRobotView.frame = CGRectMake(0, 0, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
    //[self.digitalRobotViewBgView addSubview:self.DigitalRobotView];
    
    [self.DigitalRobotView xsChangeFrame];
    
    XSWeakSelf;
    self.digitalRobotViewBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.digitalRobotViewBgView.frame = CGRectMake(digitalRobotViewBgViewX, digitalRobotViewBgViewY2, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
        
        weakSelf.digitalRobotViewBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsSelectBossTemplateView *)DigitalRobotView{
    
    if(!_DigitalRobotView){
        _DigitalRobotView = [[xsSelectBossTemplateView alloc] initWithButtonTitles:@[@"我的",@"男性",@"女性"]];
        _DigitalRobotView.delegate = self;
        
        XSWeakSelf;
        _DigitalRobotView.xsDigitalRobotCollectionCellCallbackBlock = ^(xsSelectDigitalRobotCollectionViewCellModel * _Nonnull cbModel, NSInteger aspectRatio, NSInteger categoryId) {
            
            
            XSLogMethod
            NSLog(@"cbModel.previewImage==%@\n",cbModel.previewImage);
            NSLog(@"aspectRatio==%ld\n",aspectRatio);

            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsChangeDigitalRobotIdAndpreviewImageWithModel:cbModel];
            });
            
//            if(weakSelf.recordUserDragView){
//                if([weakSelf.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
//                    
//                    xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)weakSelf.recordUserDragView;
//                }
//            }
            
            

        };
    }
    return _DigitalRobotView;
}
- (xsBossIpBottomBaseView *)digitalRobotViewBgView{
    if(!_digitalRobotViewBgView){
        _digitalRobotViewBgView = [[xsBossIpBottomBaseView alloc] init];
        _digitalRobotViewBgView.backgroundColor = UIColor.whiteColor;
        _digitalRobotViewBgView.tag = 0;
        _digitalRobotViewBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_digitalRobotViewBgView];
    }
    return _digitalRobotViewBgView;
}
- (void)xsChangeDigitalRobotIdAndpreviewImageWithModel:(xsSelectDigitalRobotCollectionViewCellModel *)ModelIdPreView{
    
    
    
    if(ModelIdPreView.isClickFreeCustom){
     
        
        [self xsTellUniPageToFreeCustView];
    }
    else{
        
        if(ModelIdPreView.cellIsBeSelect){
            
            self.xsNumberRobot_digitalHumanModel = ModelIdPreView;
            //数字人id
            self.xsNumberRobot_digitalHumanId= [NSString stringWithFormat:@"%ld",ModelIdPreView.Id];
            
            NSData *urlImageData =  [[SDImageCache sharedImageCache]diskImageDataForKey:ModelIdPreView.previewImage];
            if(urlImageData){
                //weakSelf.iconImageView.image = [UIImage imageWithData:urlImageData];
                //tempCropImageView.image = [UIImage imageWithData:urlImageData];
                
                [self xsChangeDigitalRobotWithImage:[UIImage imageWithData:urlImageData] withDigitalHumanId:ModelIdPreView.Id withDigitalHumanIdImageUrl:[ModelIdPreView.previewImage copy]];
            }
            else{
                XSWeakSelf;
                [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:ModelIdPreView.previewImage] options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
                    
                } completed:^(UIImage * _Nullable image22, NSData * _Nullable data22, NSError * _Nullable error, BOOL finished) {
                    if (image22) {
                        [[SDImageCache sharedImageCache] storeImageDataToDisk:data22 forKey:ModelIdPreView.previewImage];
                        
                        // 图片下载成功，将其设置到UIImageView中
                        dispatch_async(dispatch_get_main_queue(), ^{
                            //tempCropImageView.image = [UIImage imageWithData:data22];
                            [weakSelf xsChangeDigitalRobotWithImage:image22 withDigitalHumanId:ModelIdPreView.Id withDigitalHumanIdImageUrl:[ModelIdPreView.previewImage copy]];
                        });
                    } else {
                        // 处理错误
                        NSLog(@"Error downloading image: %@", error);
                    }
                }];
            }
        }
        else{
            self.xsNumberRobot_digitalHumanModel = nil;
            //数字人id
            self.xsNumberRobot_digitalHumanId= 0;
            [self xsChangeDigitalRobotWithImage:[UIImage new] withDigitalHumanId:0 withDigitalHumanIdImageUrl:[NSString new]];
        }
        
    }
}
#pragma mark 修改老板ip图片背景
- (void)xsChangeDigitalRobotWithImage:(UIImage *)digitalRototImg withDigitalHumanId:(NSInteger)digitalHumanIdInt withDigitalHumanIdImageUrl:(NSString *)digitalHumanIdImageUrlStr{
    
    // 数字人 1素材 2标题 3字幕
    for(xsCropBaseView *tempCropItem in self.self.TestRobotCropCurrentMarray){
          if(tempCropItem.cropTag==0){
              xsCropBaseImageView *tempImageView = (xsCropBaseImageView *)tempCropItem;
              
              tempImageView.digitalHumanId = digitalHumanIdInt;
              tempImageView.digitalHumanIdImageUrl = digitalHumanIdImageUrlStr;
              
              tempImageView.image = digitalRototImg;
          }
      }
}


#pragma mark xsSelectBossTemplateViewProtoCol
- (void)xsSelectBossTemplateXButtonBeClick:(UIButton *)btn{
    
    NSLog(@"xsgouButtonBeClick");
    
    [self hide_xsDigitalRobotBossIPViewBgView];
    
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
}

- (void)hide_xsDigitalRobotBossIPViewBgView{
    
    CGFloat digitalRobotViewBgViewW = ScreenW;
    CGFloat digitalRobotViewBgViewH = 400.0;
    CGFloat digitalRobotViewBgViewX = 0;
    CGFloat digitalRobotViewBgViewY = ScreenH;//-digitalRobotViewBgViewH;
    //CGFloat digitalRobotViewBgViewY2 = ScreenH-digitalRobotViewBgViewH;
    
    XSWeakSelf;
    self.digitalRobotViewBgView.xsIsShow = NO;
    self.digitalRobotViewBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.digitalRobotViewBgView.frame = CGRectMake(digitalRobotViewBgViewX, digitalRobotViewBgViewY, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
        
        weakSelf.digitalRobotViewBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.digitalRobotViewBgView.hidden = YES;
    }];
}

#pragma mark 通知uiapp跳转到免费定制页面
- (void)xsTellUniPageToFreeCustView{
    
    //action  1返回上个页面  2002跳转到免费定制页面
    //[self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2002"}} domChanges:nil];
}

#pragma mark 老板IP end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -




#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 配音 对应的视图
- (void)show_xsCongfgonfigurationMusicView{
    CGFloat digitalRobotViewBgViewW = ScreenW;
    CGFloat digitalRobotViewBgViewH = 400.0+kIPhoneBottom_Height;
    CGFloat digitalRobotViewBgViewX = 0;
    CGFloat digitalRobotViewBgViewY = ScreenH;//-digitalRobotViewBgViewH;
    CGFloat digitalRobotViewBgViewY2 = ScreenH-digitalRobotViewBgViewH;
    
    if(!_congfgonfigurationMusicBgView){
        [self.bgView addSubview:self.congfgonfigurationMusicBgView];
    }
    
    self.congfgonfigurationMusicBgView.xsIsShow = YES;
    self.congfgonfigurationMusicBgView.hidden = NO;
    //[self.bgView addSubview:self.digitalRobotViewBgView];
    self.congfgonfigurationMusicBgView.frame = CGRectMake(digitalRobotViewBgViewX, digitalRobotViewBgViewY, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
    
    if(!_congfgonfigurationMusicView){
        [self.congfgonfigurationMusicBgView addSubview:self.congfgonfigurationMusicView];
        self.congfgonfigurationMusicView.frame = CGRectMake(0, 0, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
        [self.congfgonfigurationMusicView xsChangeFrame];
    }
    
    CGFloat originalW = self.topImgBgView.bounds.size.width;
    CGFloat originalH = self.topImgBgView.bounds.size.height;
    
    CGFloat zoomY = kNavigationBar_Height;
    CGFloat zoomX = 0;

    CGFloat zoomH = kScreenH - digitalRobotViewBgViewH - zoomY - 10;
    CGFloat zoomW = originalW/originalH*zoomH;
    
    CGFloat ratioH = zoomH / originalH;
    CGFloat ratioW = zoomW / originalW;
    
    XSWeakSelf;
    self.congfgonfigurationMusicBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        self.congfgonfigurationMusicBgView.frame = CGRectMake(digitalRobotViewBgViewX, digitalRobotViewBgViewY2, digitalRobotViewBgViewW, digitalRobotViewBgViewH);
        self.congfgonfigurationMusicBgView.alpha = 1.0;
        self.topImgBgView.transform = CGAffineTransformMakeScale(ratioW, ratioH);//缩小为原来的倍数。
        self.topImgBgView.y = zoomY;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsConfigurationMusicView *)congfgonfigurationMusicView{
    if(!_congfgonfigurationMusicView){
        _congfgonfigurationMusicView = [[xsConfigurationMusicView alloc] initWithButtonTitles:@[@"我的",@"官方"]];
        _congfgonfigurationMusicView.delegate = self;
        
        XSWeakSelf;
        
        ////audioType;// 0我的 1官方
        _congfgonfigurationMusicView.xsConfigurationMusicCellCallbackBlock = ^(xsConfigurationMusicCollectionViewCellModel * _Nonnull cbModel, NSInteger audioType) {
            weakSelf.xsConfigurationMusicCollectionViewCellMd = cbModel;
            if(!kStringIsEmpty(cbModel.name)){
                dispatch_async(dispatch_get_main_queue(), ^{
                    //xsDigitalRobotBottomView
//                    if(_RobotBottomView){
//                        [_RobotBottomView xsChangeMyVoiceButtonTitle:cbModel.name];
//                    }
                    [weakSelf xsUpdateMyVoiceButtonTitleName:cbModel.name];
                });
            }
            
            if(audioType==0){// 我的
                NSLog(@"点击了我的配音--cbModel.name=%@\n",cbModel.name);
                
                //数字人声音id
                weakSelf.xsNumberRobot_digitalHumanVoiceId = [NSString stringWithFormat:@"%ld",cbModel.Id];
                
                // 弹出显示音频参数
                //if(cbModel.isBeClick){
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [weakSelf show_AudioConditioningSettingV];
                        
                        [weakSelf xsChangCongfgonfigurationMusicAllCellClickState:NO withAudioType:audioType];
                    });
                //}
            }
            else if(audioType==1){//官方
                NSLog(@"点击了官方配音--cbModel.name=%@\n",cbModel.name);
                
                //语音模板id
                weakSelf.xsNumberRobot_voiceTemplateId = [NSString stringWithFormat:@"%ld",cbModel.Id];
                
                // 弹出显示音频参数
               // if(cbModel.isBeClick){
                    dispatch_async(dispatch_get_main_queue(), ^{
                        
                        [weakSelf show_AudioConditioningSettingV];
                        
                        [weakSelf xsChangCongfgonfigurationMusicAllCellClickState:NO withAudioType:audioType];
                    });
                //}
            }
        };
    }
    return _congfgonfigurationMusicView;
}
- (void)xsUpdateMyVoiceButtonTitleName:(NSString *)nameStr{
    
    if(_RobotBottomView){
        [_RobotBottomView xsChangeMyVoiceButtonTitle:nameStr];
    }
}
////audioType;// 0我的 1官方
// 改变全部的cell为选中或者未选中状态 YES选中  NO未选中
- (void)xsChangCongfgonfigurationMusicAllCellClickState:(BOOL)clickStatu withAudioType:(NSInteger)audioType{
    
    // 是0 把1也就是官方选中状态变成未选中
    if(audioType==0){
        
        [self.congfgonfigurationMusicView xsConfigurationMusicVChangAllCellClickState:clickStatu withAudioType:1];
    }
    else if(audioType==1){
        // 是1 把0也就是我的选中状态变成未选中
        [self.congfgonfigurationMusicView xsConfigurationMusicVChangAllCellClickState:clickStatu withAudioType:0];
    }
}


#pragma mark xsConfigurationMusicViewProtoCol
- (void)xsConfigurationMusicViewxsXbuttonBeClick:(UIButton *)btn{

    NSLog(@"xsConfigurationMusicViewxsXbuttonBeClick");

    [self hide_xsCongfgonfigurationMusicView];
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
}

- (void)hide_xsCongfgonfigurationMusicView{
    self.congfgonfigurationMusicBgView.xsIsShow = NO;
    self.congfgonfigurationMusicBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        self.congfgonfigurationMusicBgView.y = kScreenH;
        self.congfgonfigurationMusicBgView.alpha = 0.0;
        self.topImgBgView.transform = CGAffineTransformIdentity;
        self.topImgBgView.y = kNavigationBar_Height;
    } completion:^(BOOL finished) {
        self.congfgonfigurationMusicBgView.hidden = YES;
    }];
}


- (xsBossIpBottomBaseView *)congfgonfigurationMusicBgView{
    if(!_congfgonfigurationMusicBgView){
        _congfgonfigurationMusicBgView = [[xsBossIpBottomBaseView alloc] init];
        _congfgonfigurationMusicBgView.backgroundColor = UIColor.clearColor;
        _congfgonfigurationMusicBgView.tag = 1;
        _congfgonfigurationMusicBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_congfgonfigurationMusicBgView];
    }
    return _congfgonfigurationMusicBgView;
}
#pragma mark 配音end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 模板 对应的视图
- (void)show_xsTemplateViewView{
    
    
    CGFloat xsTemplateViewBgViewW = ScreenW;
    CGFloat xsTemplateViewBgViewH = 400.0;
    CGFloat xsTemplateViewBgViewX = 0;
    CGFloat xsTemplateViewBgViewY = ScreenH;//-xsTemplateViewBgViewH;
    CGFloat xsTemplateViewBgViewY2 = ScreenH-xsTemplateViewBgViewH;
    
    if(!_templateViewViewBgView){
        [self.bgView addSubview:self.templateViewViewBgView];
    }
    
    if(!_templateViewView){
        [self.templateViewViewBgView addSubview:self.templateViewView];
    }
    
    self.templateViewViewBgView.hidden = NO;
    //[self.bgView addSubview:self.xsTemplateViewBgView];
    self.templateViewViewBgView.frame = CGRectMake(xsTemplateViewBgViewX, xsTemplateViewBgViewY, xsTemplateViewBgViewW, xsTemplateViewBgViewH);
    
    self.templateViewView.frame = CGRectMake(0, 0, xsTemplateViewBgViewW, xsTemplateViewBgViewH);
    //[self.xsTemplateViewBgView addSubview:self.DigitalRobotView];
    
    XSWeakSelf;
    self.templateViewViewBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.templateViewViewBgView.frame = CGRectMake(xsTemplateViewBgViewX, xsTemplateViewBgViewY2, xsTemplateViewBgViewW, xsTemplateViewBgViewH);
        
        weakSelf.templateViewViewBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsTemplateView *)templateViewView{
    
    if(!_templateViewView){
        _templateViewView = [[xsTemplateView alloc] initWithButtonTitles:@[@"我的",@"热门",@"广告营销",@"短视频口播",@"生活服务",@"情感",@"知识",@"咨询",@"跨境电商",@"医疗保健",@"绿幕数字人",@"名片"]];
        _templateViewView.delegate = self;
    }
    return _templateViewView;
}
#pragma mark xsTemplateViewProtoCol
- (void)xsTemplateViewgouButtonBeClick:(UIButton *)btn{

    NSLog(@"xsTemplateViewgouButtonBeClick");

    [self hide_xsTemplateViewView];
}

- (void)hide_xsTemplateViewView{
    
    CGFloat xsTemplateViewBgViewW = ScreenW;
    CGFloat xsTemplateViewBgViewH = 400.0;
    CGFloat xsTemplateViewBgViewX = 0;
    CGFloat xsTemplateViewBgViewY = ScreenH;//-xsTemplateViewBgViewH;
    //CGFloat xsTemplateViewBgViewY2 = ScreenH-xsTemplateViewBgViewH;
    
    XSWeakSelf;
    self.templateViewViewBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.templateViewViewBgView.frame = CGRectMake(xsTemplateViewBgViewX, xsTemplateViewBgViewY, xsTemplateViewBgViewW, xsTemplateViewBgViewH);
        
        weakSelf.templateViewViewBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.templateViewViewBgView.hidden = YES;
    }];
}


- (xsBossIpBottomBaseView *)templateViewViewBgView{
    if(!_templateViewViewBgView){
        _templateViewViewBgView = [[xsBossIpBottomBaseView alloc] init];
        _templateViewViewBgView.backgroundColor = UIColor.clearColor;
    }
    return _templateViewViewBgView;
}
#pragma mark 模板end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -




#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选择背景 对应的视图
- (void)show_xsBackgroundView{
    
    
    CGFloat xsBackgroundViewBgViewW = ScreenW;
    CGFloat xsBackgroundViewBgViewH = 400.0+kIPhoneBottom_Height;
    CGFloat xsBackgroundViewBgViewX = 0;
    CGFloat xsBackgroundViewBgViewY = ScreenH;//-xsBackgroundViewBgViewH;
    CGFloat xsBackgroundViewBgViewY2 = ScreenH-xsBackgroundViewBgViewH;
    
    if(!_BackgroundViewBgView){
        [self.bgView addSubview:self.BackgroundViewBgView];
    }
    
    if(!_BackgroundView){
        [self.BackgroundViewBgView addSubview:self.BackgroundView];
    }
    
    self.BackgroundViewBgView.xsIsShow = YES;
    self.BackgroundViewBgView.hidden = NO;
    //[self.bgView addSubview:self.xsBackgroundViewBgView];
    self.BackgroundViewBgView.frame = CGRectMake(xsBackgroundViewBgViewX, xsBackgroundViewBgViewY, xsBackgroundViewBgViewW, xsBackgroundViewBgViewH);
    
    self.BackgroundView.frame = CGRectMake(0, 0, xsBackgroundViewBgViewW, xsBackgroundViewBgViewH);
    //[self.xsBackgroundViewBgView addSubview:self.DigitalRobotView];
    
    [self.BackgroundView xsSetFrame];
    
    XSWeakSelf;
    self.BackgroundViewBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.BackgroundViewBgView.frame = CGRectMake(xsBackgroundViewBgViewX, xsBackgroundViewBgViewY2, xsBackgroundViewBgViewW, xsBackgroundViewBgViewH);
        
        weakSelf.BackgroundViewBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsBackgroundView *)BackgroundView{
    
    if(!_BackgroundView){
        _BackgroundView = [[xsBackgroundView alloc] initWithButtonTitles:@[@"我的",@"纯色",@"官方"]];
        _BackgroundView.delegate = self;
    }
    return _BackgroundView;
}
- (xsBossIpBottomBaseView *)BackgroundViewBgView{
    if(!_BackgroundViewBgView){
        _BackgroundViewBgView = [[xsBossIpBottomBaseView alloc] init];
        _BackgroundViewBgView.backgroundColor = UIColor.clearColor;
        _BackgroundViewBgView.tag = 2;
        _BackgroundViewBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_BackgroundViewBgView];
    }
    return _BackgroundViewBgView;
}
#pragma mark xsBackgroundViewProtoCol
- (void)xsBackgroundViewXbuttonBeClick:(UIButton *)btn{

    NSLog(@"xsBackgroundViewXbuttonBeClick");

    [self hide_xsBackgroundView];
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
}

// collectionTyp 0我的  1纯色  2官方  cellModel是其中的三个要判断
- (void)xsBackgroundCollectionViewCellCallBackWithModel:(id)cellModel withCollectionTyp:(NSInteger)collectionTyp{
    NSLog(@"xsBackgroundCollectionViewCellCallBackWithModel");
    
    XSWeakSelf;
    if(collectionTyp==0){
        //我的
        xsBossMyCollectionViewCellModel *MyModel = cellModel;
        
        if(!kStringIsEmpty(MyModel.url)){
            
            //背景图片地址
            self.xsNumberRobot_backgroundImageUrl = [MyModel.url copy];
        }
        
        if(!MyModel.isAddType){
            
            NSData *urlImageData =  [[SDImageCache sharedImageCache]diskImageDataForKey:MyModel.url];
            if(urlImageData){
                weakSelf.bossBackgroundImage.image = [UIImage imageWithData:urlImageData];
            }
            else{
                [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:MyModel.url] options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
                    
                } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
                        if (image) {
                            [[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:MyModel.url];
                            
                            // 图片下载成功，将其设置到UIImageView中
                            dispatch_async(dispatch_get_main_queue(), ^{
                                weakSelf.bossBackgroundImage.image = image;
                            });
                        } else {
                            // 处理错误
                            NSLog(@"Error downloading image: %@", error);
                        }
                }];
            }
        }
        else{
            
            // 通知vue上传背景图 2008
            
            //action  1返回上个页面  2002跳转到免费定制页面
            // action  2003返回图片或者视频的路径
            // action 2004 跳转到视频字幕
            // action 2005 预览 导出
            // typeStatu 2 图片 3视频
            // action 2006 弹出上传图片 视频框
            // action 2007 删除素材
            // action 2008 弹出上传背景图片 视频框
            // action 2009 删除我的背景图像
            
            
//[weakSelf fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2008"}} domChanges:nil];
        }
    }
    else if(collectionTyp==1){
        //纯色
        xsSolidColorCollectionViewCellModel *SolidModel = cellModel;
        NSString *colorStr = SolidModel.bossBgColor;
        
        
        if(!kStringIsEmpty(colorStr)){
            // 背景颜色 (纯色背景) 和背景图片只能选一个传
            self.xsNumberRobot_backgroundColor = [colorStr copy];
        }
        
        UIColor *chunseColor = [UIColor xsColorwithHexString:colorStr Alpha:1.0];
        
        
        
        UIImage *cunseImage = [UIColor xsColorAsImage:chunseColor withImaegSize:CGSizeMake(self.bossBackgroundImage.width, self.bossBackgroundImage.height)];
        
        self.bossBackgroundImage.image = cunseImage;
    
        
    }
    else if(collectionTyp==2){
        //官方
        xsAuthorityCollectionViewCellModel *AuthorityModel = cellModel;
        
        if(!kStringIsEmpty(AuthorityModel.xsRecordSelectImageUrl)){
            
            //背景图片地址
            self.xsNumberRobot_backgroundImageUrl = [AuthorityModel.xsRecordSelectImageUrl copy];
        }
        
        if(!AuthorityModel.isAddType){
            
            NSData *urlImageData =  [[SDImageCache sharedImageCache]diskImageDataForKey:AuthorityModel.xsRecordSelectImageUrl];
            if(urlImageData){
                weakSelf.bossBackgroundImage.image = [UIImage imageWithData:urlImageData];
            }
            else{
                [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:AuthorityModel.xsRecordSelectImageUrl] options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
                    
                } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
                        if (image) {
                            [[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:AuthorityModel.xsRecordSelectImageUrl];
                            
                            // 图片下载成功，将其设置到UIImageView中
                            dispatch_async(dispatch_get_main_queue(), ^{
                                weakSelf.bossBackgroundImage.image = image;
                            });
                        } else {
                            // 处理错误
                            NSLog(@"Error downloading image: %@", error);
                        }
                }];
            }
        }
    }
}
// 点击了我的 cell里面的delete图片按钮
- (void)xsBackgroundCollectionViewMyCollectionCellDeleteButtonCallWithModel:(xsBossMyCollectionViewCellModel *)cellModel{
    NSLog(@"xsBackgroundCollectionViewMyCollectionCellDeleteButtonCallWithModel");
    
    //action  1返回上个页面  2002跳转到免费定制页面
    // action  2003返回图片或者视频的路径
    // action 2004 跳转到视频字幕
    // action 2005 预览 导出
    // typeStatu 2 图片 3视频
    // action 2006 弹出上传图片 视频框
    // action 2007 删除素材
    // action 2008 弹出上传背景图片 视频框
    // action 2009 删除我的背景图像
    
    NSString *bossBackgroundImgIdStr = [NSString stringWithFormat:@"%ld",cellModel.Id];
//[weakSelf fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2009",@"bossBackgroundImgId":bossBackgroundImgIdStr}} domChanges:nil];
}
#pragma mark vue告诉插件我的 bossTypeState==2背景图片上传成功 bossTypeState==3背景图片删除成功
//UNI_EXPORT_METHOD(@selector(bossVueUplowndBackGroundImageSuccesfulOrDeleteBackgroundImageSuccesful:))
- (void)bossVueUplowndBackGroundImageSuccesfulOrDeleteBackgroundImageSuccesful:(NSDictionary *)Paramer{
    
    if([Paramer isKindOfClass:[NSDictionary class]]){
        NSInteger bossipTypeInt = [Paramer[@"bossTypeState"] integerValue];
        // 重新获取我的 背景图片数据
        
        if(_BackgroundView){
            [_BackgroundView xsBossBackgroundVTellMyCollectionViewReloadData];
        }
    }
    
}


- (void)hide_xsBackgroundView{
    
    CGFloat xsBackgroundViewBgViewW = ScreenW;
    CGFloat xsBackgroundViewBgViewH = 400.0;
    CGFloat xsBackgroundViewBgViewX = 0;
    CGFloat xsBackgroundViewBgViewY = ScreenH;//-xsBackgroundViewBgViewH;
    //CGFloat xsBackgroundViewBgViewY2 = ScreenH-xsBackgroundViewBgViewH;
    
    XSWeakSelf;
    self.BackgroundViewBgView.xsIsShow = NO;
    self.BackgroundViewBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.BackgroundViewBgView.frame = CGRectMake(xsBackgroundViewBgViewX, xsBackgroundViewBgViewY, xsBackgroundViewBgViewW, xsBackgroundViewBgViewH);
        
        weakSelf.BackgroundViewBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.BackgroundViewBgView.hidden = YES;
    }];
}



#pragma mark 选择背景end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -



#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 文字 对应的视图
- (void)show_xsTextView{
    
    
 
    
    if(!_xsTextBgView){
        [self.bgView addSubview:self.xsTextBgView];
        
    }
    
    if(!_xsTextView){
        [self.xsTextBgView addSubview:self.xsTextView];
        self.xsTextView.tag = 0;// 0:键盘 1:样式
    }
    
    
    CGFloat xsTextViewBgViewW = ScreenW;
    CGFloat xsTextViewBgViewH = 370.0+kIPhoneBottom_Height;
    CGFloat  xsTextViewBgViewH2 = 110.0;
    CGFloat xsTextViewBgViewX = 0;
    //CGFloat xsTextViewBgViewY = ScreenH;//-xsTextViewBgViewH;
    CGFloat xsTextViewBgViewY2 = ScreenH-xsTextViewBgViewH2;
    
//    if(self.xsTextView.tag==0){//0:键盘 1:样式
//        xsTextViewBgViewY2 = ScreenH-xsTextViewBgViewH2;
//    }
//    else{
        xsTextViewBgViewY2 = ScreenH-xsTextViewBgViewH;
//    }
    
    self.xsTextBgView.xsIsShow = YES;
    self.xsTextBgView.hidden = NO;
    //[self.bgView addSubview:self.xsTextViewBgView];
    self.xsTextBgView.frame = CGRectMake(xsTextViewBgViewX, xsTextViewBgViewY2, xsTextViewBgViewW, xsTextViewBgViewH);
    
    self.xsTextView.frame = CGRectMake(0, 0, xsTextViewBgViewW, xsTextViewBgViewH);
    //[self.xsTextViewBgView addSubview:self.DigitalRobotView];
    
    [self.xsTextView xsSetFrame];
    
    XSWeakSelf;
    self.xsTextBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsTextBgView.frame = CGRectMake(xsTextViewBgViewX, xsTextViewBgViewY2, xsTextViewBgViewW, xsTextViewBgViewH);
        
        weakSelf.xsTextBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
    //点击底部文字时是否创建CropLabel
    [self xsShowTextViewWithIsCreateCropLabel];
    
    if(_RobotBottomView){
        [_RobotBottomView xsChangeTopViewIsHidden:YES];
    }
}

- (xsTextView *)xsTextView{
    
    if(!_xsTextView){
        _xsTextView = [[xsTextView alloc] initWithButtonTitles:@[@"键盘",@"样式"]];
        _xsTextView.delegate = self;
    }
    return _xsTextView;
}
- (void)hide_xsTextView{
    
    CGFloat xsTextViewBgViewW = ScreenW;
    CGFloat xsTextViewBgViewH = 400.0;
    CGFloat xsTextViewBgViewX = 0;
    CGFloat xsTextViewBgViewY = ScreenH;//-xsTextViewBgViewH;
    //CGFloat xsTextViewBgViewY2 = ScreenH-xsTextViewBgViewH;
    
    XSWeakSelf;
    self.xsTextBgView.xsIsShow = NO;
    self.xsTextBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsTextBgView.frame = CGRectMake(xsTextViewBgViewX, xsTextViewBgViewY, xsTextViewBgViewW, xsTextViewBgViewH);
        
        weakSelf.xsTextBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.xsTextBgView.hidden = YES;
             
    }];
    
    if(_RobotBottomView){
        [_RobotBottomView xsChangeTopViewIsHidden:NO];
    }
}


- (xsBossIpBottomBaseView *)xsTextBgView{
    if(!_xsTextBgView){
        _xsTextBgView = [[xsBossIpBottomBaseView alloc] init];
        _xsTextBgView.backgroundColor = UIColor.clearColor;
        _xsTextBgView.tag = 3;
        _xsTextBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_xsTextBgView];
    }
    return _xsTextBgView;
}


#pragma mark xsTextViewProtoCol
- (void)xsTextViewxsVerifyButtonBeClick:(UIButton *)btn{

    NSLog(@"xsTextViewxsVerifyButtonBeClick");

    [self hide_xsTextView];
    
   
    
    if(self.xsEditeDigitalRobotTitleVBgView.hidden==YES){
        //// CropTage 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
        [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
    }
    
}

#pragma mark  0:键盘   1:样式
- (void)xsKeybordStyleButtonBeClickEventCallBack:(NSInteger)tag{

    
    CGFloat xsTextViewBgViewW = ScreenW;
    CGFloat xsTextViewBgViewH = 370.0;
    CGFloat xsTextViewBgViewX = 0;
    //CGFloat xsTextViewBgViewY = ScreenH;//-xsTextViewBgViewH;
    
    if(tag==0){// 键盘
        xsTextViewBgViewH = 110.0;
    }
    else{//  样式
        xsTextViewBgViewH = 370.0;
        CGFloat xsTextViewBgViewY2 = ScreenH-xsTextViewBgViewH;
        self.xsTextBgView.frame = CGRectMake(xsTextViewBgViewX, xsTextViewBgViewY2, xsTextViewBgViewW, xsTextViewBgViewH);
    }
    
    //xsTextViewBgViewH = 370.0;
    self.xsTextView.tag = tag;// 0:键盘 1:样式
    

    
    //[self hide_xsTextView];
//    [self xsShowBottomEditorStatuWithCropTg:4];
}

#pragma mark 文字view里 点击return键调用
- (void)xsTexTextfieldTextReturnKeyBeClickChange:(NSString *)textChangeString{
    NSString *tempStr = [NSString stringWithFormat:@"xsTexTextfieldTextReturnKeyBeClickChange--==%@",textChangeString];
    XSLogMethod2(tempStr)

    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        tempLabel.text = textChangeString;
        tempLabel.recodeBaseStr = [textChangeString copy];
        
        if(tempLabel.cropTag==2){
            // 标题
            
            //标题
            self.xsNumberRobot_title = [textChangeString copy];
        }
        else if(tempLabel.cropTag==3){
            //字幕
            
            // 字幕 视频（字幕）内容
//            self.xsNumberRobot_text = [textChangeString copy];
            if(_RobotBottomView){
                [_RobotBottomView xsChangeInputCopywritingTextVWithString:[textChangeString copy]];
            }
        }
        
    }

}
#pragma mark 文字view里 点击文本修改键调用
- (void)xsTexTextfieldTextChange:(NSString *)textChangeString{
    
    NSString *tempStr = [NSString stringWithFormat:@"xsTexTextfieldTextChange--textChangeString==%@",textChangeString];
    XSLogMethod2(tempStr)
    
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        tempLabel.text = textChangeString;
        tempLabel.recodeBaseStr = [textChangeString copy];
        
        if(tempLabel.cropTag==2){
            // 标题
            
            //标题
            self.xsNumberRobot_title = [textChangeString copy];
        }
        else if(tempLabel.cropTag==3){
            //字幕
            
            // 字幕 视频（字幕）内容
//            self.xsNumberRobot_text = [textChangeString copy];
            if(_RobotBottomView){
                [_RobotBottomView xsChangeInputCopywritingTextVWithString:[textChangeString copy]];
            }
        }
        
    }
//    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
//       // xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
////        tempCropImageView.image = [];
//    }

//    //隐藏全部view的四个角和四条边的view(label和imgview)
//    [self xsHidenAllRectViewWithCrop];
//    //xsHiddenAllTopLeftDeleteButton
//    [self xsHiddenAllTopLeftDeleteButton];
}

#pragma mark 字体类别事件
- (void)xsTexViewFontFamilyEvent:(xsFontFamilyData *)xsFontFamilyDict{
    self.xsTexViewFontFamilyColModel = xsFontFamilyDict;
    
//    @property (nonatomic,copy) NSString *fontNameLinux;// = MaokenAssortedSans;
//    @property (nonatomic,copy) NSString *fontNameWindows;// = "\U732b\U5543\U4ec0\U9526\U9ed1";
//    @property (nonatomic,assign) NSInteger Id;// = 1;
//    @property (nonatomic,copy) NSString *imageUrl;// = "https://peacc4f.png";
//    @property (nonatomic,copy) NSString *ossUrl;// = "https://pay028e.ttf";
    
    NSString *tempStr = [NSString stringWithFormat:@"xsTexViewFontFamilyEvent-xsFontFamilyDict.fontNameLinux==%@ xsFontFamilyDict.fontNameWindows==%@   self.xsTexViewTextSizeF==%f",xsFontFamilyDict.fontNameLinux,xsFontFamilyDict.fontNameWindows,self.xsTexViewTextSizeF];
    XSLogMethod2(tempStr)
    
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        tempLabel.xsFontFamilyMd.fontNameLinux = [xsFontFamilyDict.fontNameLinux copy];
        tempLabel.xsFontFamilyMd.fontNameLinuxServer = [xsFontFamilyDict.fontNameLinuxServer copy];
//        [tempLabel setFont:[UIFont fontWithName:xsFontFamilyDict.fontNameLinux size:self.xsTexViewTextSizeF]];
        
        [self xsTextUpdateTextFontStyleWith:tempLabel];
    }
    
}
#pragma mark 文字的描边图片事件()
- (void)xsTexViewFontBackgroundEvent:(xsFontStyleData *)xsFontBackgroundDict{
    self.xsTexViewFontBackgroundColModel = xsFontBackgroundDict;
    
    NSString *tempStr = [NSString stringWithFormat:@"描边图片被点击xsTexViewFontBackgroundEvent-xsFontFamilyDict.image==%@ xsFontFamilyDict.outlineColour==%@",xsFontBackgroundDict.image,xsFontBackgroundDict.outlineColour];
    XSLogMethod2(tempStr)
    
    
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        
        if(!kStringIsEmpty(xsFontBackgroundDict.outlineColour)){
            tempLabel.xsFontStyleMd.outlineColour = [xsFontBackgroundDict.outlineColour copy];
            tempLabel.xsTextContourColorString = [xsFontBackgroundDict.outlineColour copy];
        }
        if(!kStringIsEmpty(xsFontBackgroundDict.primaryColour)){
            tempLabel.xsFontStyleMd.primaryColour = [xsFontBackgroundDict.primaryColour copy];
            tempLabel.xsTextColorString = [xsFontBackgroundDict.primaryColour copy];
        }
        if(!kStringIsEmpty(xsFontBackgroundDict.backColour)){
            tempLabel.xsFontStyleMd.backColour = [xsFontBackgroundDict.backColour copy];
        }
        tempLabel.xsFontStyleMd.borderStyle = xsFontBackgroundDict.borderStyle;
        tempLabel.xsFontStyleMd.outlineBorderWidth = xsFontBackgroundDict.borderStyle;
        
        NSString *tempStr = [tempLabel.recodeBaseStr copy];
        //tempLabel.recodeBaseStr = [tempStr copy];
        
        NSString *xsColorString = xsFontBackgroundDict.outlineColour;
        NSString *xsprimaryColourString = xsFontBackgroundDict.primaryColour;
        
        tempLabel.xsTextColorString = [xsprimaryColourString copy];
        tempLabel.xsTextContourColorString = [xsColorString copy];
        
        
        [self xsTextUpdateTextFontStyleWith:tempLabel];
//        if(!kStringIsEmpty(tempStr)){
//            if(!kStringIsEmpty(xsColorString)){
//                
//                // 创建一个 NSMutableAttributedString
//                NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tempStr];
//                  
//                // 设置文字样式
//                [attributedString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:self.xsTexViewTextSizeF] range:NSMakeRange(0, [attributedString length])];
//                
//                if(!kStringIsEmpty(xsprimaryColourString)){
//                    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor xsColorwithHexString:xsprimaryColourString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
//                }
//                
//                  
//                // 设置描边颜色（注意：这不一定在所有情况下都有效）
//                [attributedString addAttribute:NSStrokeColorAttributeName value:[UIColor xsColorwithHexString:xsColorString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
//                
//                
//                [attributedString addAttribute:NSStrokeWidthAttributeName value:@-2.0 range:NSMakeRange(0, [attributedString length])]; // 负数表示在文字内部描边
//                  
//                // 尝试将 NSAttributedString 设置为 UILabel 的 attributedText（可能不会按预期显示描边）
//                tempLabel.attributedText = attributedString;
//            }
//        }
    }
    //    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
    //        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
    ////        tempCropImageView.image = [];
    //    }
    
    
}
#pragma mark 文字颜色事件(背景颜色??)
- (void)xsTexViewTextColorEvent:(NSString *)xsColorString{
    self.xsTexViewTextColorHexString = xsColorString;
    
    NSString *tempStr = [NSString stringWithFormat:@"文字颜色xsTexViewTextColorEvent==%@",xsColorString];
    XSLogMethod2(tempStr)
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        tempLabel.xsTextColorString = xsColorString;
        tempLabel.xsFontStyleMd.primaryColour = xsColorString;
        
//        tempLabel.textColor = [UIColor xsColorwithHexString:xsColorString Alpha:1.0];
        
        [self xsTextUpdateTextFontStyleWith:tempLabel];
    }
    //    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
    //        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
    ////        tempCropImageView.image = [];
    //    }
    
}
#pragma mark 文字描边事件
- (void)xsTexViewTextContourEvent:(NSString *)xsColorString{
    
    self.xsTexViewTextContourString = xsColorString;
    NSString *tempStr = [NSString stringWithFormat:@"文字描边xsTexViewTextContourEvent==%@",xsColorString];
    XSLogMethod2(tempStr)
    
    
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        tempLabel.xsTextContourColorString = xsColorString;
        tempLabel.xsFontStyleMd.outlineColour = xsColorString;
//        tempLabel.shadowColor = [UIColor xsColorwithHexString:xsColorString Alpha:1.0];
//        // 设置UILabel的阴影偏移量，以产生描边效果
//        tempLabel.layer.shadowOffset = CGSizeMake(1, 1);
//        tempLabel.layer.shadowOpacity = 1.0;
//        tempLabel.layer.shadowRadius = 1.0;
        
        
        NSString *tempStr = tempLabel.text;
        tempLabel.recodeBaseStr = [tempStr copy];
        
//        if(!kStringIsEmpty(tempStr)){
//            // 创建一个 NSMutableAttributedString
//            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tempStr];
//              
//            // 设置文字样式
//            [attributedString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:self.xsTexViewTextSizeF] range:NSMakeRange(0, [attributedString length])];
//              
//            // 设置描边颜色（注意：这不一定在所有情况下都有效）
//            [attributedString addAttribute:NSStrokeColorAttributeName value:[UIColor xsColorwithHexString:xsColorString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
//            [attributedString addAttribute:NSStrokeWidthAttributeName value:@-2.0 range:NSMakeRange(0, [attributedString length])]; // 负数表示在文字内部描边
//              
//            // 尝试将 NSAttributedString 设置为 UILabel 的 attributedText（可能不会按预期显示描边）
//            tempLabel.attributedText = attributedString;
//        }
          
        [self xsTextUpdateTextFontStyleWith:tempLabel];
        
    }
    //    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
    //        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
    ////        tempCropImageView.image = [];
    //    }
    
    
}
#pragma mark 文字大小事件
- (void)xsTexViewTextSizeEvent:(CGFloat )xsTextSizet{
    
    self.xsTexViewTextSizeF = xsTextSizet;
    
    NSString *tempStr = [NSString stringWithFormat:@"文字大小xsTexViewTextSizeEvent==%f",xsTextSizet];
    XSLogMethod2(tempStr)
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        
        tempLabel.xsTextSizeF =  xsTextSizet;
//        tempLabel.font = [UIFont systemFontOfSize:xsTextSizet];
        
        
        [self xsTextUpdateTextFontStyleWith:tempLabel];
    }
    //    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
    //        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
    ////        tempCropImageView.image = [];
    //    }
}
#pragma mark 文字描边边框大小事件
- (void)xsTexViewTextContourOutlineSizeEvent:(CGFloat )xsTextSizet{
    
    //self.xsTexViewTextSizeF = xsTextSizet;
    
    NSString *tempStr = [NSString stringWithFormat:@"文字描边边框大小xsTexViewTextSizeEvent==%f",xsTextSizet];
    XSLogMethod2(tempStr)
    
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
        
        //tempLabel.xsTextSizeF =  xsTextSizet;
//        tempLabel.font = [UIFont systemFontOfSize:xsTextSizet];
        tempLabel.xsFontStyleMd.outlineBorderWidth = xsTextSizet;
        
        [self xsTextUpdateTextFontStyleWith:tempLabel];
    }
    //    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
    //        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
    ////        tempCropImageView.image = [];
    //    }
}

#pragma mark 更新文字大小字体颜色描边等....
- (void)xsTextUpdateTextFontStyleWith:(xsCropBaseLabel *)cropLabel{
    
    
    NSString *tempStr = cropLabel.recodeBaseStr;
    //tempLabel.recodeBaseStr = [tempStr copy];
    
    if(!kStringIsEmpty(tempStr)){
        
        
        
        NSString *text = tempStr;
        UIFont *font; // 设置字体大小为18
        if(!kStringIsEmpty(cropLabel.xsFontFamilyMd.fontNameLinux)){
            font = [UIFont fontWithName:cropLabel.xsFontFamilyMd.fontNameLinux size:cropLabel.xsTextSizeF]; // 设置字体大小为18
        }
        else{
            font = [UIFont systemFontOfSize:cropLabel.xsTextSizeF];;//[UIFont fontWithName:@"PingFangSC-Regular" size:cropLabel.xsTextSizeF];
        }
        UIColor *textColor = [UIColor xsColorwithHexString:cropLabel.xsTextColorString Alpha:1.0]; // 设置文字颜色为黑色
        CGFloat strokeWidth = -cropLabel.xsFontStyleMd.outlineBorderWidth; // 设置描边宽度为1
        UIColor *strokeColor = [UIColor xsColorwithHexString:cropLabel.xsTextContourColorString Alpha:1.0]; // 设置描边颜色为红色

        NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
        
        [attributes setObject:font forKey:NSFontAttributeName];
        [attributes setObject:textColor forKey:NSForegroundColorAttributeName];
        
        [attributes setObject:[NSNumber numberWithFloat:strokeWidth] forKey:NSStrokeWidthAttributeName];
        [attributes setObject:strokeColor forKey:NSStrokeColorAttributeName];
        
        
        
        
//        // 设置文字背景色
//        [attributes setObject:UIColor.greenColor forKey:NSBackgroundColorAttributeName];
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text attributes:attributes];
//        [attributedString addAttributes:@{NSForegroundColorAttributeName:UIColor.whiteColor} range:NSMakeRange(0, text.length)];

//        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
        cropLabel.attributedText = attributedString;
        
      
        
        cropLabel.textColor = textColor;
        
        
//        // 创建一个 NSMutableAttributedString
//        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tempStr];
//          
//        // 设置文字大小跟文字类别
//        [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:cropLabel.xsFontFamilyMd.fontNameLinux size:cropLabel.xsTextSizeF] range:NSMakeRange(0, [attributedString length])];
//
//        
//        
//        if(!kStringIsEmpty(cropLabel.xsTextColorString)){
//            // 设置文字颜色
//            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor xsColorwithHexString:cropLabel.xsTextColorString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
//        }
//         
////        // 设置背景颜色
////        [attributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor xsColorwithHexString:cropLabel.xsTextColorString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
//         
//          
//        if(!kStringIsEmpty(cropLabel.xsTextContourColorString)){
//            
//            // 注意这个描边有问题
////            // 设置描边颜色（注意：这不一定在所有情况下都有效）
////            [attributedString addAttribute:NSStrokeColorAttributeName value:[UIColor xsColorwithHexString:cropLabel.xsTextContourColorString Alpha:1.0] range:NSMakeRange(0, [attributedString length])];
////            [attributedString addAttribute:NSStrokeWidthAttributeName value:@(cropLabel.xsFontStyleMd.outlineBorderWidth) range:NSMakeRange(0, [attributedString length])]; // -2.0负数表示在文字内部描边
//            
//            
////            cropLabel.layer.shadowColor = [[UIColor xsColorwithHexString:cropLabel.xsTextContourColorString Alpha:1.0] CGColor]; // 描边颜色
////            cropLabel.layer.shadowOffset = CGSizeMake(0, 0); // 偏移量，设为0,0时看起来就像描边
////            cropLabel.layer.shadowOpacity = 1.0; // 描边的不透明度
////            cropLabel.layer.shadowRadius = cropLabel.xsFontStyleMd.outlineBorderWidth; // 描边的粗细，可以调整
        }
        
        
       
          
//        // 尝试将 NSAttributedString 设置为 UILabel 的 attributedText（可能不会按预期显示描边）
//        cropLabel.attributedText = attributedString;
//    }
    
}



#pragma mark 文字end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 贴图 对应的视图
- (void)show_xsChartletView{
    
    
    CGFloat xsChartletViewBgViewW = ScreenW;
    CGFloat xsChartletViewBgViewH = 400.0+kIPhoneBottom_Height;
    CGFloat xsChartletViewBgViewX = 0;
    CGFloat xsChartletViewBgViewY = ScreenH;//-xsChartletViewBgViewH;
    CGFloat xsChartletViewBgViewY2 = ScreenH-xsChartletViewBgViewH;
    
    if(!_ChartletViewBgView){
        [self.bgView addSubview:self.ChartletViewBgView];
    }
    
    if(!_ChartletViewView){
        [self.ChartletViewBgView addSubview:self.ChartletViewView];
    }
    
    self.ChartletViewBgView.hidden = NO;
    //[self.bgView addSubview:self.xsChartletViewBgView];
    self.ChartletViewBgView.frame = CGRectMake(xsChartletViewBgViewX, xsChartletViewBgViewY, xsChartletViewBgViewW, xsChartletViewBgViewH);
    
    self.ChartletViewView.frame = CGRectMake(0, 0, xsChartletViewBgViewW, xsChartletViewBgViewH);
    //[self.xsChartletViewBgView addSubview:self.DigitalRobotView];
    
    XSWeakSelf;
    self.ChartletViewBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.ChartletViewBgView.frame = CGRectMake(xsChartletViewBgViewX, xsChartletViewBgViewY2, xsChartletViewBgViewW, xsChartletViewBgViewH);
        
        weakSelf.ChartletViewBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsChartletView *)ChartletViewView{
    
    if(!_ChartletViewView){
        _ChartletViewView = [[xsChartletView alloc] initWithButtonTitles:@[@"热门",@"指引",@"装饰",@"人物",@"氛围",@"大头",@"遮挡",@"边框"]];
        _ChartletViewView.delegate = self;
    }
    return _ChartletViewView;
}
#pragma mark xsChartletViewProtoCol
- (void)xsChartletViewgouButtonBeClick:(UIButton *)btn{

    NSLog(@"xsChartletViewgouButtonBeClick");

    [self hide_xsChartletView];
}

- (void)hide_xsChartletView{
    
    CGFloat xsChartletViewBgViewW = ScreenW;
    CGFloat xsChartletViewBgViewH = 400.0;
    CGFloat xsChartletViewBgViewX = 0;
    CGFloat xsChartletViewBgViewY = ScreenH;//-xsChartletViewBgViewH;
    //CGFloat xsChartletViewBgViewY2 = ScreenH-xsChartletViewBgViewH;
    
    XSWeakSelf;
    self.ChartletViewBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.ChartletViewBgView.frame = CGRectMake(xsChartletViewBgViewX, xsChartletViewBgViewY, xsChartletViewBgViewW, xsChartletViewBgViewH);
        
        weakSelf.ChartletViewBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.ChartletViewBgView.hidden = YES;
    }];
}


- (UIView *)ChartletViewBgView{
    if(!_ChartletViewBgView){
        _ChartletViewBgView = [[UIView alloc] init];
        _ChartletViewBgView.backgroundColor = UIColor.clearColor;
    }
    return _ChartletViewBgView;
}
#pragma mark 贴图end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选择背景音乐 对应的视图
- (void)show_BossIPBackgroundView{
    
    
    CGFloat BossIPBackgroundViewBgViewW = ScreenW;
    CGFloat BossIPBackgroundViewBgViewH = 400.0;
    CGFloat BossIPBackgroundViewBgViewX = 0;
    CGFloat BossIPBackgroundViewBgViewY = ScreenH;//-BossIPBackgroundViewBgViewH;
    CGFloat BossIPBackgroundViewBgViewY2 = ScreenH-BossIPBackgroundViewBgViewH;
    
    if(!_BossIPBackgroundViewBgView){
        [self.bgView addSubview:self.BossIPBackgroundViewBgView];
    }
    
    if(!_BossIPBackgroundView){
        [self.BossIPBackgroundViewBgView addSubview:self.BossIPBackgroundView];
    }
    
    self.BossIPBackgroundViewBgView.xsIsShow = YES;
    self.BossIPBackgroundViewBgView.hidden = NO;
    //[self.bgView addSubview:self.BossIPBackgroundViewBgView];
    self.BossIPBackgroundViewBgView.frame = CGRectMake(BossIPBackgroundViewBgViewX, BossIPBackgroundViewBgViewY, BossIPBackgroundViewBgViewW, BossIPBackgroundViewBgViewH);
    
    self.BossIPBackgroundView.frame = CGRectMake(0, 0, BossIPBackgroundViewBgViewW, BossIPBackgroundViewBgViewH);
    //[self.BossIPBackgroundViewBgView addSubview:self.DigitalRobotView];
    
    [self.BossIPBackgroundView xsChangeFrame];
    XSWeakSelf;
    self.BossIPBackgroundViewBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.BossIPBackgroundViewBgView.frame = CGRectMake(BossIPBackgroundViewBgViewX, BossIPBackgroundViewBgViewY2, BossIPBackgroundViewBgViewW, BossIPBackgroundViewBgViewH);
        
        weakSelf.BossIPBackgroundViewBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsBossIPBackgroundView *)BossIPBackgroundView{
    
    if(!_BossIPBackgroundView){
        _BossIPBackgroundView = [[xsBossIPBackgroundView alloc] init];
        _BossIPBackgroundView.delegate = self;
    }
    return _BossIPBackgroundView;
}
#pragma mark BossIPBackgroundViewProtoCol
- (void)xsBossIPBackgroundViewCloseButtonBeClick:(UIButton *)btn{
        
    NSLog(@"BossIPBackgroundViewgouButtonBeClick");

    [self hide_BossIPBackgroundView];
    
    // 如果使用uniapp播放音乐就销毁播放音乐
    [self xsStopUniappPlayMusic];
    
    //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
    [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
}
- (void)xsBossIPBackgroundViewPlayAudioButtonBeClick:(UIButton *)button{
    
    XSLogMethod2(@"xsBossIPBackgroundViewPlayAudioButtonBeClick")
    
    [self show_BackgroundAudioConditioningSettingV];
    
}
- (void)xsBossIPBackgroundTabelViewCellUseButtonBeClick:(xsBossIPBackgroundTableViewCellModel *)sendModel{
    
    
    NSString *tempStr = [NSString stringWithFormat:@"sendModel.title==%@",sendModel.title];
    XSLogMethod2(tempStr)
    
    
}
- (void)xsBossIPBackgroundTabelViewCellDeleteButtonBeClick:(xsBossIPBackgroundTableViewCellModel *)sendModel{
    
    NSString *tempStr = [NSString stringWithFormat:@"sendModel.title==%@",sendModel.title];
    XSLogMethod2(tempStr)
    
    
}

#pragma mark 选择背景音 cell被点击
- (void)xsBossIPBackgroundTabelViewCellBeClick:(xsBossIPBackgroundTableViewCellModel *)sendModel{
    NSString *tempStr = [NSString stringWithFormat:@"sendModel.title==%@",sendModel.title];
    XSLogMethod2(tempStr)
    
    
    //背景音乐id
    self.xsNumberRobot_musicId = [NSString stringWithFormat:@"%ld",sendModel.Id];
    
    
    //记录选中的背景音
    self.xsBossIPBackgroundTableViewCellMd = sendModel;
    
    if(self.xsBossIPBackgroundTableViewCellMd.isUse){
        [self xsUseUniappPlayMusicWithModel:sendModel];
    }
    else{
        [self xsStopUniappPlayMusic];
    }
    
    
}

#pragma mark  顶部分类标题被点击
- (void)xsBossIPBackgroundTopMusicTagBeClickBk:(xsMusicTagModel *)topTagModel{
    
    // 如果使用uniapp播放音乐就销毁播放音乐
    [self xsStopUniappPlayMusic];
}
#pragma mark 如果使用uniapp播放音乐就销毁播放音乐
- (void)xsStopUniappPlayMusic{
    
    [self xsStopConfigurationAudioMisicPlay];
}
#pragma mark 使用uniapp播放音乐
- (void)xsUseUniappPlayMusicWithModel:(xsBossIPBackgroundTableViewCellModel *)pmodel{
    if(!kStringIsEmpty(pmodel.playbackUrl)){
        
        [self xsStopConfigurationAudioMisicPlay];
        [self playConfigurationAudioFromURL:[NSURL URLWithString:pmodel.playbackUrl] withRate:1.0 withVolume:100.0];
    }
}

- (void)hide_BossIPBackgroundView{
    
    CGFloat BossIPBackgroundViewBgViewW = ScreenW;
    CGFloat BossIPBackgroundViewBgViewH = 400.0;
    CGFloat BossIPBackgroundViewBgViewX = 0;
    CGFloat BossIPBackgroundViewBgViewY = ScreenH;//-BossIPBackgroundViewBgViewH;
    //CGFloat BossIPBackgroundViewBgViewY2 = ScreenH-BossIPBackgroundViewBgViewH;
    
    XSWeakSelf;
    self.BossIPBackgroundViewBgView.xsIsShow = NO;
    self.BossIPBackgroundViewBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.BossIPBackgroundViewBgView.frame = CGRectMake(BossIPBackgroundViewBgViewX, BossIPBackgroundViewBgViewY, BossIPBackgroundViewBgViewW, BossIPBackgroundViewBgViewH);
        
        weakSelf.BossIPBackgroundViewBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.BossIPBackgroundViewBgView.hidden = YES;
    }];
}


- (xsBossIpBottomBaseView *)BossIPBackgroundViewBgView{
    if(!_BossIPBackgroundViewBgView){
        _BossIPBackgroundViewBgView = [[xsBossIpBottomBaseView alloc] init];
        _BossIPBackgroundViewBgView.backgroundColor = UIColor.clearColor;
        _BossIPBackgroundViewBgView.tag = 4;
        _BossIPBackgroundViewBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_BossIPBackgroundViewBgView];
    }
    return _BossIPBackgroundViewBgView;
}
#pragma mark 选择背景音乐 end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选择配音--音频参数view 对应的视图


- (void)show_AudioConditioningSettingV{
    
    
    CGFloat xsAudioConditioningSettingBgViewW = ScreenW;
    CGFloat xsAudioConditioningSettingBgViewH = 240.0;
    CGFloat xsAudioConditioningSettingBgViewX = 0;
    CGFloat xsAudioConditioningSettingBgViewY = ScreenH;//-xsAudioConditioningSettingBgViewH;
    CGFloat xsAudioConditioningSettingBgViewY2 = ScreenH-xsAudioConditioningSettingBgViewH;
    
    if(!_xsAudioConditioningSettingBgView){
        [self.bgView addSubview:self.xsAudioConditioningSettingBgView];
    }
    
    if(!_xsAudioConditioningSettingV){
        [self.xsAudioConditioningSettingBgView addSubview:self.xsAudioConditioningSettingV];
    }
    
    self.xsAudioConditioningSettingBgView.hidden = NO;
    //[self.bgView addSubview:self.xsAudioConditioningSettingBgView];
    self.xsAudioConditioningSettingBgView.frame = CGRectMake(xsAudioConditioningSettingBgViewX, xsAudioConditioningSettingBgViewY, xsAudioConditioningSettingBgViewW, xsAudioConditioningSettingBgViewH);
    
    self.xsAudioConditioningSettingV.frame = CGRectMake(0, 0, xsAudioConditioningSettingBgViewW, xsAudioConditioningSettingBgViewH);
    //[self.xsAudioConditioningSettingBgView addSubview:self.DigitalRobotView];
    
    [self.xsAudioConditioningSettingV xsChangeFrame];
    XSWeakSelf;
    self.xsAudioConditioningSettingBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsAudioConditioningSettingBgView.frame = CGRectMake(xsAudioConditioningSettingBgViewX, xsAudioConditioningSettingBgViewY2, xsAudioConditioningSettingBgViewW, xsAudioConditioningSettingBgViewH);
        
        weakSelf.xsAudioConditioningSettingBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}

- (xsAudioConditioningSettingView *)xsAudioConditioningSettingV{
    
    if(!_xsAudioConditioningSettingV){
        // musicType 0选择配音中的音频参数 2选择背景音中的音频参数
        _xsAudioConditioningSettingV = [[xsAudioConditioningSettingView alloc] initWithMusicType:0];
        _xsAudioConditioningSettingV.delegate_AudioConditioningSetting = self;
    }
    return _xsAudioConditioningSettingV;
}
#pragma mark xsAudioConditioningSettingVProtoCol
- (void)xsAudioConditioningSettingViewgouButtonBeClick:(UIButton *)btn{
        
    NSLog(@"xsAudioConditioningSettingVgouButtonBeClick");

    [self hide_AudioConditioningSettingV];
}

- (void)hide_AudioConditioningSettingV{
    
    CGFloat xsAudioConditioningSettingBgViewW = ScreenW;
    CGFloat xsAudioConditioningSettingBgViewH = 240.0;//400.0;
    CGFloat xsAudioConditioningSettingBgViewX = 0;
    CGFloat xsAudioConditioningSettingBgViewY = ScreenH;//-xsAudioConditioningSettingBgViewH;
    //CGFloat xsAudioConditioningSettingBgViewY2 = ScreenH-xsAudioConditioningSettingBgViewH;
    
    XSWeakSelf;
    self.xsAudioConditioningSettingBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsAudioConditioningSettingBgView.frame = CGRectMake(xsAudioConditioningSettingBgViewX, xsAudioConditioningSettingBgViewY, xsAudioConditioningSettingBgViewW, xsAudioConditioningSettingBgViewH);
        
        weakSelf.xsAudioConditioningSettingBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.xsAudioConditioningSettingBgView.hidden = YES;
    }];
}


- (UIView *)xsAudioConditioningSettingBgView{
    if(!_xsAudioConditioningSettingBgView){
        _xsAudioConditioningSettingBgView = [[UIView alloc] init];
        _xsAudioConditioningSettingBgView.backgroundColor = UIColor.clearColor;
    }
    return _xsAudioConditioningSettingBgView;
}



#pragma mark xsAudioConditioningSettingViewProtoCol


// musicType 0选择配音中的音频参数 2选择背景音中的音频参数
#pragma mark  音量改变
- (void)xsAudioVolumeChange:(CGFloat)cgValue withMusicType:(NSInteger)musicType{
    
    XSLogMethod2(@"xsAudioVolumeChange")
    
    
    if(musicType==0){
        self.xsAudioVolumeNumberF = cgValue;
        
        
        
        //NSInteger tempVolumeN = cgValue;
        //声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
        self.xsNumberRobot_volume = [NSString stringWithFormat:@"%.0f",cgValue];
        
        [self xsChangeConfigurationPlayAudioWithRate:self.xsLanguageSpeedNumberF withVolume:self.xsAudioVolumeNumberF];
    }
    else if(musicType==2){
        self.xsBackroundMusicAudioVolumeNumberF = cgValue;
        
        //背景音乐音量
        self.xsNumberRobot_musicVolume= [NSString stringWithFormat:@"%.0f",self.xsBackroundMusicAudioVolumeNumberF];
        
        [self xsChangeConfigurationPlayAudioWithRate:1.0 withVolume:self.xsBackroundMusicAudioVolumeNumberF];
    }
    
}
#pragma mark  语速改变
- (void)xsLanguageSpeedChange:(CGFloat)cgValue{
    
    XSLogMethod2(@"xsLanguageSpeedChange")
    
    self.xsLanguageSpeedNumberF = cgValue;
    
    // 声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
    self.xsNumberRobot_speechRate = [NSString stringWithFormat:@"%.1f",self.xsLanguageSpeedNumberF];
    
    [self xsChangeConfigurationPlayAudioWithRate:self.xsLanguageSpeedNumberF withVolume:self.xsAudioVolumeNumberF];
}

#pragma mark 试听按钮被点击
// 试听按钮被点击
- (void)xsTryListenbuttonEvent:(UIButton *)button{
    
    XSLogMethod2(@"xsTryListenbuttonEvent")
    
//    // 这个是记录选中的配音
//    self.xsConfigurationMusicCollectionViewCellMd;
    
    //使用uniapp来播放选中的配音
    [self xsUseUniappPlayConfigurationMusicWithModel:self.xsConfigurationMusicCollectionViewCellMd];
    
}

#pragma mark 使用uniapp来播放选中的配音
- (void)xsUseUniappPlayConfigurationMusicWithModel:(xsConfigurationMusicCollectionViewCellModel *)model{
    
//if(!kStringIsEmpty(model.name)){
//    //xsDigitalRobotBottomView
//    if(_RobotBottomView){
//        [_RobotBottomView xsChangeMyVoiceButtonTitle:model.name];
//    }
//}
   
//
//    //  音量大小
//    @property (nonatomic,assign)CGFloat xsAudioVolumeNumberF;
//    //  语速快慢
//    @property (nonatomic,assign)CGFloat xsLanguageSpeedNumberF;
//@"https://payment-writemall-com.oss-cn-shenzhen.aliyuncs.com/analysis-others/f73e1423-5778-427f-84d5-4acb5a32ec16.mp3"
//    @"https://ai-video-writemall-com.oss-cn-shenzhen.aliyuncs.com/voice/ecb2b3a3-5447-4de0-8410-4d4a4e74ff74.mp3"
//    [self playConfigurationAudioFromURL:[NSURL URLWithString:@"https://payment-writemall-com.oss-cn-shenzhen.aliyuncs.com/analysis-others/f73e1423-5778-427f-84d5-4acb5a32ec16.mp3"] withRate:self.xsLanguageSpeedNumberF withVolume:self.xsAudioVolumeNumberF];
//    
//    return;
//    //audioType;// 0我的 1官方
//    [self getAudioDataWithAudioType:1];return;
    
    //audioType;// 0我的 1官方
    if(model.audioType==0){
        // @"https://ai-video-writemall-com.oss-cn-shenzhen.aliyuncs.com/voice/ecb2b3a3-5447-4de0-8410-4d4a4e74ff74.mp3"
        if(!kStringIsEmpty(self.xsConfigurationMusicCollectionViewCellMd.previewVoice)){
            
            [self playConfigurationAudioFromURL:[NSURL URLWithString:self.xsConfigurationMusicCollectionViewCellMd.previewVoice] withRate:self.xsLanguageSpeedNumberF withVolume:self.xsAudioVolumeNumberF];
        }
        else{
            // 没有配音地址要获取配音地址
            //audioType;// 0我的 1官方
            [self getAudioDataWithAudioType:0];
        }
    }
    else if(model.audioType==1){
        if(!kStringIsEmpty(self.xsConfigurationMusicCollectionViewCellMd.previewVoice)){
            
            [self playConfigurationAudioFromURL:[NSURL URLWithString:self.xsConfigurationMusicCollectionViewCellMd.previewVoice] withRate:self.xsLanguageSpeedNumberF withVolume:self.xsAudioVolumeNumberF];
        }
        else{
            // 没有配音地址要获取配音地址
            //audioType;// 0我的 1官方
            [self getAudioDataWithAudioType:1];
        }
    }

    
}

// x按钮被点击
// musicType 0选择配音中的音频参数 2选择背景音中的音频参数
- (void)xsAudioConditioningSettingVXbuttonEvent:(UIButton *)button  withMusicType:(NSInteger)musicType{
    XSLogMethod2(@"xsAudioConditioningSettingVXbuttonEvent")

    if(musicType==0){
        [self hide_AudioConditioningSettingV];
        
        [self xsStopConfigurationAudioMisicPlay];
        
    }
    else if(musicType==2){
        [self hide_BackgroundAudioConditioningSettingV];
        
        [self xsStopConfigurationAudioMisicPlay];
    }
    
}


#pragma mark 选择配音--音频参数view end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选择添加素材view 对应的视图


- (void)show_SelectAddMaterialV{
    
    
    CGFloat xsSelectAddMaterialBgViewW = ScreenW;
    CGFloat xsSelectAddMaterialBgViewH = 400.0;
    CGFloat xsSelectAddMaterialBgViewX = 0;
    CGFloat xsSelectAddMaterialBgViewY = ScreenH;//-xsSelectAddMaterialBgViewH;
    CGFloat xsSelectAddMaterialBgViewY2 = ScreenH-xsSelectAddMaterialBgViewH;
    
    if(!_xsSelectAddMaterialBgView){
        [self.bgView addSubview:self.xsSelectAddMaterialBgView];
    }
    
    if(!_xsSelectAddMaterialV){
        [self.xsSelectAddMaterialBgView addSubview:self.xsSelectAddMaterialV];
    }
    
    _xsSelectAddMaterialBgView.xsIsShow = YES;
    _xsSelectAddMaterialBgView.hidden = NO;
    //[self.bgView addSubview:xsSelectAddMaterialBgView];
    _xsSelectAddMaterialBgView.frame = CGRectMake(xsSelectAddMaterialBgViewX, xsSelectAddMaterialBgViewY, xsSelectAddMaterialBgViewW, xsSelectAddMaterialBgViewH);
    
    self.xsSelectAddMaterialV.frame = CGRectMake(0, 0, xsSelectAddMaterialBgViewW, xsSelectAddMaterialBgViewH);
    //[xsSelectAddMaterialBgView addSubview:self.DigitalRobotView];
    
    [self.xsSelectAddMaterialV xsChangeFrame];
    XSWeakSelf;
    _xsSelectAddMaterialBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsSelectAddMaterialBgView.frame = CGRectMake(xsSelectAddMaterialBgViewX, xsSelectAddMaterialBgViewY2, xsSelectAddMaterialBgViewW, xsSelectAddMaterialBgViewH);
        
        weakSelf.xsSelectAddMaterialBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}


#pragma mark xsSelectAddMaterialVProtoCol
- (void)xsSelectAddMaterialVgouButtonBeClick:(UIButton *)btn{
        
    NSLog(@"xsSelectAddMaterialVgouButtonBeClick");

    [self hide_SelectAddMaterialV];
}

- (void)hide_SelectAddMaterialV{
    
    CGFloat xsSelectAddMaterialBgViewW = ScreenW;
    CGFloat xsSelectAddMaterialBgViewH = 400.0;//400.0;
    CGFloat xsSelectAddMaterialBgViewX = 0;
    CGFloat xsSelectAddMaterialBgViewY = ScreenH;//-xsSelectAddMaterialBgViewH;
    //CGFloat xsSelectAddMaterialBgViewY2 = ScreenH-xsSelectAddMaterialBgViewH;
    
    XSWeakSelf;
    weakSelf.xsSelectAddMaterialBgView.alpha = 1.0;
    self.xsSelectAddMaterialBgView.xsIsShow = NO;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsSelectAddMaterialBgView.frame = CGRectMake(xsSelectAddMaterialBgViewX, xsSelectAddMaterialBgViewY, xsSelectAddMaterialBgViewW, xsSelectAddMaterialBgViewH);
        
        weakSelf.xsSelectAddMaterialBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.xsSelectAddMaterialBgView.hidden = YES;
    }];
}


- (xsBossIpBottomBaseView *)xsSelectAddMaterialBgView{
    if(!_xsSelectAddMaterialBgView){
        _xsSelectAddMaterialBgView = [[xsBossIpBottomBaseView alloc] init];
        _xsSelectAddMaterialBgView.backgroundColor = UIColor.clearColor;
        _xsSelectAddMaterialBgView.tag = 5;
        _xsSelectAddMaterialBgView.xsIsShow = NO;
        [self.xsRecrodBottomShowPanViewMarray addObject:_xsSelectAddMaterialBgView];
    }
    return _xsSelectAddMaterialBgView;
}
- (xsSelectAddMaterialView *)xsSelectAddMaterialV{
    
    if(!_xsSelectAddMaterialV){
        _xsSelectAddMaterialV = [[xsSelectAddMaterialView alloc] initWithButtonTitles:@[@"全部",@"图片",@"视频"]];
        _xsSelectAddMaterialV.delegate = self;
        
        XSWeakSelf;
        //collectionType;// 0全部 3图片 1视频
        // 0时 fileType传@""  3时fileType传@"3" 1时fileType传@"1"
        _xsSelectAddMaterialV.xsSelectAddMaterialCellCallbackBlock = ^(xsSelectAddMaterialCollectionViewCellModel * _Nonnull cbModel,NSInteger collecionTyp) {
          
            NSString *tempString = [NSString stringWithFormat:@"xsSelectAddMaterialCellCallbackBlock--collectionType=%ld",collecionTyp];
            XSLogMethod2(tempString);
            
            
            if(cbModel.isAddType){
                dispatch_async(dispatch_get_main_queue(), ^{
                    [weakSelf selecterdButtonAction:nil];
                });
                
                return;
            }
            if(cbModel.isSelectModel){
                if(weakSelf.xsSelectAddMaterialModelMarray.count>0){
                    
                    BOOL isHaveSelectModel = NO;
                    for (xsSelectAddMaterialCollectionViewCellModel *findSelectItemModel in weakSelf.xsSelectAddMaterialModelMarray) {
                        if(cbModel.Id==findSelectItemModel.Id){
                            isHaveSelectModel = YES;
                            break;
                        }
                    }
                    if(!isHaveSelectModel){
                        [weakSelf.xsSelectAddMaterialModelMarray addObject:cbModel];
                    }
                }
                else{
                    [weakSelf.xsSelectAddMaterialModelMarray addObject:cbModel];
                }
            }
            else{
                
                xsSelectAddMaterialCollectionViewCellModel *tempFindDeleteModel;
                for (xsSelectAddMaterialCollectionViewCellModel *findWilDeleteModel in weakSelf.xsSelectAddMaterialModelMarray) {
                    if(cbModel.Id==findWilDeleteModel.Id){
                        tempFindDeleteModel = findWilDeleteModel;
                        break;
                    }
                }
                if(tempFindDeleteModel){
                    [weakSelf.xsSelectAddMaterialModelMarray removeObject:tempFindDeleteModel];
                }
            }
            
            
            
            
            if(weakSelf.RobotBottomView){
                NSInteger xsSelectMaterialCout = weakSelf.xsSelectAddMaterialModelMarray.count;
                NSString *xsSelectMaterialString = [NSString stringWithFormat:@"%@%ld",kLocalizedString(@"素材"),xsSelectMaterialCout];
                
                [weakSelf.RobotBottomView xsChangeAddMaterialLabelText:xsSelectMaterialString];
            }
            
            
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsMaterialViewChangeAddMaterialButonTitle];
            });
        };
        _xsSelectAddMaterialV.xsSelectAddMaterialCellDeleteButtonCallbackBlock = ^(xsSelectAddMaterialCollectionViewCellModel * _Nonnull cbModelD, NSInteger collecionTyp) {

            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsShowIsDeleteMaterialWithId:cbModelD.Id];
            });
        };
    }
    return _xsSelectAddMaterialV;
}

- (void)xsShowIsDeleteMaterialWithId:(NSInteger)IdInteger{
    

    
    XSWeakSelf;
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否删除当前素材?" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        // typeStatu 2 图片 3视频
        //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
        // action 2004 跳转到视频字幕
        // action 2005 预览 导出

        // action 2007 删除素材
        NSString *deletIdStr = [NSString stringWithFormat:@"%ld",IdInteger];
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD showError:@"删除中..."];
//[weakSelf fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2007",@"deletId":deletIdStr}} domChanges:nil];
        });
        
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alert addAction:confirm];
    [alert addAction:cancel];
    UIViewController *vc = [YSHelp getCurrentVC];
    if(vc){
        [vc presentViewController:alert animated:YES completion:nil];
    }
    else{
        [MBProgressHUD showError:@"获取视图出错!"];
    }
    
}
#pragma mark 设置添加素材按钮文本
- (void)xsMaterialViewChangeAddMaterialButonTitle{
    
    XSWeakSelf;
    if(self.xsSelectAddMaterialModelMarray.count>0){
        
        
        xsSelectAddMaterialCollectionViewCellModel *firstModel = self.xsSelectAddMaterialModelMarray.firstObject;
        
        
            if(self.RobotBottomView){
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [weakSelf.RobotBottomView xsChangeAddMaterialLabelLeftIcon:firstModel.url];
                });
            }
       
        
        NSData *urlImageData =  [[SDImageCache sharedImageCache] diskImageDataForKey:firstModel.url];
        if(urlImageData){
//                weakSelf.iconImageView.image = [UIImage imageWithData:urlImageData];
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsMaterialViewChangeMaterialWithImage:[UIImage imageWithData:urlImageData]];
            });
        }
        else{
            [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:firstModel.url] options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
                
            } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
                    if (image) {
                        [[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:firstModel.url];
                        
                        // 图片下载成功，将其设置到UIImageView中
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf xsMaterialViewChangeMaterialWithImage:image];
                        });
                    } else {
                        // 处理错误
                        NSLog(@"Error downloading image: %@", error);
                    }
            }];
        }
    }
    else{
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf xsMaterialViewChangeMaterialWithImage:[UIImage imageNamed:@"bossIPEdit_icon_add"]];
        });
    }
}

#pragma mark 设置选中素材列表最先添加的图片
- (void)xsMaterialViewChangeMaterialWithImage:(UIImage *)materialImage{
    
    //TestRobotCropViewMarray记录的是拖动的四个角和四条边   0数字人  1素材 2标题 3字幕
    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)  0数字人  1素材 2标题 3字幕
//    for(xsCropBaseView *tempCropItem in self.TestRobotCropViewMarray){
//        if(tempCropItem.cropTag==3){
//            tempCropItem.hidden = hideState;
//        }
//    }
    for(xsCropBaseView *tempCropItem in self.TestRobotCropCurrentMarray){
        if(tempCropItem.cropTag==1){
            xsCropBaseImageView *tempImageView = (xsCropBaseImageView *)tempCropItem;
            tempImageView.image = materialImage;
        }
    }
}

#pragma mark xsSelectAddMaterialViewProtoCol

// x按钮被点击
- (void)xsSelectAddMaterialVXbuttonEvent:(UIButton *)button{
    XSLogMethod2(@"xsSelectAddMaterialVXbuttonEvent")

    [self hide_SelectAddMaterialV];
    
    
    if(self.xsEditeDigitalRobotTitleVBgView.hidden==YES){
        //// CropTage 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
        [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
    }
    
}


#pragma mark 选择添加素材view end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选择背景音--音频参数view 对应的视图
- (void)show_BackgroundAudioConditioningSettingV{
    
    CGFloat xsBackgroundAudioConditioningSettingBgViewW = ScreenW;
    CGFloat xsBackgroundAudioConditioningSettingBgViewH = 160.0;
    CGFloat xsBackgroundAudioConditioningSettingBgViewX = 0;
    CGFloat xsBackgroundAudioConditioningSettingBgViewY = ScreenH;//-xsBackgroundAudioConditioningSettingBgViewH;
    CGFloat xsBackgroundAudioConditioningSettingBgViewY2 = ScreenH-xsBackgroundAudioConditioningSettingBgViewH;
    
    if(!_xsBackgroundAudioConditioningSettingBgView){
        [self.bgView addSubview:self.xsBackgroundAudioConditioningSettingBgView];
    }
    
    if(!_xsBackgroundAudioConditioningSettingV){
        [self.xsBackgroundAudioConditioningSettingBgView addSubview:self.xsBackgroundAudioConditioningSettingV];
    }
    
    self.xsBackgroundAudioConditioningSettingBgView.hidden = NO;
    //[self.bgView addSubview:self.xsBackgroundAudioConditioningSettingBgView];
    self.xsBackgroundAudioConditioningSettingBgView.frame = CGRectMake(xsBackgroundAudioConditioningSettingBgViewX, xsBackgroundAudioConditioningSettingBgViewY, xsBackgroundAudioConditioningSettingBgViewW, xsBackgroundAudioConditioningSettingBgViewH);
    
    self.xsBackgroundAudioConditioningSettingV.frame = CGRectMake(0, 0, xsBackgroundAudioConditioningSettingBgViewW, xsBackgroundAudioConditioningSettingBgViewH);
    //[self.xsBackgroundAudioConditioningSettingBgView addSubview:self.DigitalRobotView];
    
    [self.xsBackgroundAudioConditioningSettingV xsChangeFrame];
    XSWeakSelf;
    self.xsBackgroundAudioConditioningSettingBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsBackgroundAudioConditioningSettingBgView.frame = CGRectMake(xsBackgroundAudioConditioningSettingBgViewX, xsBackgroundAudioConditioningSettingBgViewY2, xsBackgroundAudioConditioningSettingBgViewW, xsBackgroundAudioConditioningSettingBgViewH);
        
        weakSelf.xsBackgroundAudioConditioningSettingBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}



- (void)hide_BackgroundAudioConditioningSettingV{
    
    CGFloat xsBackgroundAudioConditioningSettingBgViewW = ScreenW;
    CGFloat xsBackgroundAudioConditioningSettingBgViewH = 160.0;//400.0;
    CGFloat xsBackgroundAudioConditioningSettingBgViewX = 0;
    CGFloat xsBackgroundAudioConditioningSettingBgViewY = ScreenH;//-xsBackgroundAudioConditioningSettingBgViewH;
    //CGFloat xsBackgroundAudioConditioningSettingBgViewY2 = ScreenH-xsBackgroundAudioConditioningSettingBgViewH;
    
    XSWeakSelf;
    self.xsBackgroundAudioConditioningSettingBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsBackgroundAudioConditioningSettingBgView.frame = CGRectMake(xsBackgroundAudioConditioningSettingBgViewX, xsBackgroundAudioConditioningSettingBgViewY, xsBackgroundAudioConditioningSettingBgViewW, xsBackgroundAudioConditioningSettingBgViewH);
        
        weakSelf.xsBackgroundAudioConditioningSettingBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.xsBackgroundAudioConditioningSettingBgView.hidden = YES;
    }];
}

- (xsAudioConditioningSettingView *)xsBackgroundAudioConditioningSettingV{
    
    if(!_xsBackgroundAudioConditioningSettingV){
        // musicType 0选择配音中的音频参数 2选择背景音中的音频参数
        _xsBackgroundAudioConditioningSettingV = [[xsAudioConditioningSettingView alloc] initWithMusicType:2];
        _xsBackgroundAudioConditioningSettingV.delegate_AudioConditioningSetting = self;
    }
    return _xsBackgroundAudioConditioningSettingV;
}

- (xsBossIpBottomBaseView *)xsBackgroundAudioConditioningSettingBgView{
    if(!_xsBackgroundAudioConditioningSettingBgView){
        _xsBackgroundAudioConditioningSettingBgView = [[xsBossIpBottomBaseView alloc] init];
        _xsBackgroundAudioConditioningSettingBgView.backgroundColor = UIColor.clearColor;
    }
    return _xsBackgroundAudioConditioningSettingBgView;
}
//// x按钮被点击
//- (void)xsBackgroundAudioConditioningSettingVXbuttonEvent:(UIButton *)button{
//    XSLogMethod2(@"xsBackgroundAudioConditioningSettingVXbuttonEvent")
//
//    [self hide_BackgroundAudioConditioningSettingV];
//}
//

//#pragma mark xsBackgroundAudioConditioningSettingVProtoCol
//- (void)xsBackgroundAudioConditioningSettingViewgouButtonBeClick:(UIButton *)btn{
//
//    NSLog(@"xsBackgroundAudioConditioningSettingVgouButtonBeClick");
//
//    [self hide_BackgroundAudioConditioningSettingV];
//}

//#pragma mark xsBackgroundAudioConditioningSettingViewProtoCol
//
//#pragma mark  音量改变
//- (void)xsAudioVolumeChange:(CGFloat)cgValue{
//
//    XSLogMethod2(@"xsAudioVolumeChange")
//
//    self.xsAudioVolumeNumberF = cgValue;
//}
////#pragma mark  语速改变
////- (void)xsLanguageSpeedChange:(CGFloat)cgValue{
////
////    XSLogMethod2(@"xsLanguageSpeedChange")
////
////    self.xsLanguageSpeedNumberF = cgValue;
////
////
////}
////
////#pragma mark 试听按钮被点击
////// 试听按钮被点击
////- (void)xsTryListenbuttonEvent:(UIButton *)button{
////
////    XSLogMethod2(@"xsTryListenbuttonEvent")
////
//////    // 这个是记录选中的配音
//////    self.xsConfigurationMusicCollectionViewCellMd;
////
////    //使用uniapp来播放选中的配音
////    [self xsUseUniappPlayConfigurationMusicWithModel:self.xsConfigurationMusicCollectionViewCellMd];
////
////}
////
////#pragma mark 使用uniapp来播放选中的配音
////- (void)xsUseUniappPlayConfigurationMusicWithModel:(xsConfigurationMusicCollectionViewCellModel *)model{
////
////    //    // 这个是记录选中的配音
////    //    self.xsConfigurationMusicCollectionViewCellMd;
//////
//////    //  音量大小
//////    @property (nonatomic,assign)CGFloat xsAudioVolumeNumberF;
//////    //  语速快慢
//////    @property (nonatomic,assign)CGFloat xsLanguageSpeedNumberF;
////
////
////}


#pragma mark 选择背景音--音频参数view end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -



#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark 选中素材列表view 对应的视图


- (void)show_HadAddMaterialListV{
    
    
    CGFloat HadAddMaterialListVBgViewW = ScreenW;
    CGFloat HadAddMaterialListVBgViewH = 400.0;
    CGFloat HadAddMaterialListVBgViewX = 0;
    CGFloat HadAddMaterialListVBgViewY = ScreenH;//-HadAddMaterialListVBgViewH;
    CGFloat HadAddMaterialListVBgViewY2 = ScreenH-HadAddMaterialListVBgViewH;
    
    if(!_HadAddMaterialListVBgView){
        [self.bgView addSubview:self.HadAddMaterialListVBgView];
    }
    
    if(!_HadAddMaterialListV){
        [self.HadAddMaterialListVBgView addSubview:self.HadAddMaterialListV];
    }
    
    _HadAddMaterialListVBgView.xsIsShow = YES;
    _HadAddMaterialListVBgView.hidden = NO;
    //[self.bgView addSubview:HadAddMaterialListVBgView];
    _HadAddMaterialListVBgView.frame = CGRectMake(HadAddMaterialListVBgViewX, HadAddMaterialListVBgViewY, HadAddMaterialListVBgViewW, HadAddMaterialListVBgViewH);
    
    self.HadAddMaterialListV.frame = CGRectMake(0, 0, HadAddMaterialListVBgViewW, HadAddMaterialListVBgViewH);
    //[HadAddMaterialListVBgView addSubview:self.DigitalRobotView];
    
    [self.HadAddMaterialListV xsChangeFrame];
    
    NSArray *tempDataArr = [NSArray arrayWithArray:self.xsSelectAddMaterialModelMarray];
    [self.HadAddMaterialListV xsReloadCollectionViewWithDataArray:tempDataArr];
    XSWeakSelf;
    _HadAddMaterialListVBgView.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.HadAddMaterialListVBgView.frame = CGRectMake(HadAddMaterialListVBgViewX, HadAddMaterialListVBgViewY2, HadAddMaterialListVBgViewW, HadAddMaterialListVBgViewH);
        
        weakSelf.HadAddMaterialListVBgView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}


- (void)hide_HadAddMaterialListV{
    
    CGFloat HadAddMaterialListVBgViewW = ScreenW;
    CGFloat HadAddMaterialListVBgViewH = 400.0;//400.0;
    CGFloat HadAddMaterialListVBgViewX = 0;
    CGFloat HadAddMaterialListVBgViewY = ScreenH;//-HadAddMaterialListVBgViewH;
    //CGFloat HadAddMaterialListVBgViewY2 = ScreenH-HadAddMaterialListVBgViewH;
    
    XSWeakSelf;
    _HadAddMaterialListVBgView.xsIsShow = NO;
    weakSelf.HadAddMaterialListVBgView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.HadAddMaterialListVBgView.frame = CGRectMake(HadAddMaterialListVBgViewX, HadAddMaterialListVBgViewY, HadAddMaterialListVBgViewW, HadAddMaterialListVBgViewH);
        
        weakSelf.HadAddMaterialListVBgView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.HadAddMaterialListVBgView.hidden = YES;
    }];
}


- (xsBossIpBottomBaseView *)HadAddMaterialListVBgView{
    if(!_HadAddMaterialListVBgView){
        _HadAddMaterialListVBgView = [[xsBossIpBottomBaseView alloc] init];
        _HadAddMaterialListVBgView.backgroundColor = UIColor.clearColor;
        _HadAddMaterialListVBgView.xsIsShow=NO;
        _HadAddMaterialListVBgView.tag = 6;
    }
    return _HadAddMaterialListVBgView;
}
- (xsHadAddMaterialListView *)HadAddMaterialListV{
    
    if(!_HadAddMaterialListV){
        _HadAddMaterialListV = [[xsHadAddMaterialListView alloc] initWithSelectMaterialData:self.xsSelectAddMaterialModelMarray];
        _HadAddMaterialListV.delegate = self;
        
        XSWeakSelf;
        //collectionType;// 0全部 3图片 1视频
        // 0时 fileType传@""  3时fileType传@"3" 1时fileType传@"1"
        _HadAddMaterialListV.xsHadAddMaterialListCellCallbackBlock = ^(xsSelectAddMaterialCollectionViewCellModel * _Nonnull cbModel,NSInteger collecionTyp) {
          
            NSString *tempString = [NSString stringWithFormat:@"xsHadAddMaterialListCellCallbackBlock--collectionType=%ld",collecionTyp];
            XSLogMethod2(tempString);
            
            
//            dispatch_async(dispatch_get_main_queue(), ^{
//                [weakSelf xsDeleteHadAddMaterialListWithModel:cbModel];
//            });
            
        };
        _HadAddMaterialListV.xsHadAddMaterialListCellTopXbuttonCallbackBlock = ^(xsSelectAddMaterialCollectionViewCellModel * _Nonnull cbModel2, NSInteger collecionTyp2) {
            NSString *tempString = [NSString stringWithFormat:@"xsHadAddMaterialListCellTopXbuttonCallbackBlock--collecionTyp2=%ld",collecionTyp2];
            XSLogMethod2(tempString);
            
            
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsDeleteHadAddMaterialListWithModel:cbModel2];
            });
        };
    }
    return _HadAddMaterialListV;
}

#pragma mark 删除已经被选中的model
- (void)xsDeleteHadAddMaterialListWithModel:(xsSelectAddMaterialCollectionViewCellModel *)deletModel{
    
    xsSelectAddMaterialCollectionViewCellModel *findModel;
    for (xsSelectAddMaterialCollectionViewCellModel *tempModel in self.xsSelectAddMaterialModelMarray) {
        if(tempModel.Id==deletModel.Id){
            findModel = tempModel;
            break;
        }
    }
    
    if(findModel){
        [self.xsSelectAddMaterialModelMarray removeObject:findModel];
    }
    
    
    
    if(_xsSelectAddMaterialV){
        findModel.isSelectModel = NO;
        //collectionType;// 0全部 3图片 1视频
        [_xsSelectAddMaterialV xsUpdataMaterialWithModel:findModel withCollectionType:findModel.collectionType];
    }
    
    if(_HadAddMaterialListV){
        [_HadAddMaterialListV xsHadAddMaterialListDeleteWithModel:findModel withCollectionType:findModel.collectionType];
    }
    
    if(self.xsSelectAddMaterialModelMarray.count>0){
        xsSelectAddMaterialCollectionViewCellModel *firstModel = self.xsSelectAddMaterialModelMarray.firstObject;
        
        XSWeakSelf;
        NSData *urlImageData =  [[SDImageCache sharedImageCache]diskImageDataForKey:firstModel.url];
        if(urlImageData){
    //                weakSelf.iconImageView.image = [UIImage imageWithData:urlImageData];
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf xsMaterialViewChangeMaterialWithImage:[UIImage imageWithData:urlImageData]];
            });
        }
        else{
            [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:firstModel.url] options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
                
            } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
                    if (image) {
                        [[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:firstModel.url];
                        
                        // 图片下载成功，将其设置到UIImageView中
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf xsMaterialViewChangeMaterialWithImage:image];
                        });
                    } else {
                        // 处理错误
                        NSLog(@"Error downloading image: %@", error);
                    }
            }];
        }
    }
    else{
        [self xsMaterialViewChangeMaterialWithImage:[UIImage imageNamed:@"bossIPDefaultImage"]];
    }
    
    if(self.RobotBottomView){
        NSInteger xsSelectMaterialCout = self.xsSelectAddMaterialModelMarray.count;
        
        NSString *xsSelectMaterialString = [NSString stringWithFormat:@"%@%ld",kLocalizedString(@"素材"),xsSelectMaterialCout];
        if(xsSelectMaterialCout<=0){
            xsSelectMaterialString = kLocalizedString(@"添加素材");
        }
        
        
        [self.RobotBottomView xsChangeAddMaterialLabelText:xsSelectMaterialString];
        //显示添加素材按钮
        [self.RobotBottomView xsChangeAddMaterialLabelLeftIcon:@"bossIPEdit_icon_add"];
    }
    
    
}


#pragma mark xsHadAddMaterialListViewProtoCol

// x按钮被点击
- (void)xsHadAddMaterialListVXbuttonEvent:(UIButton *)button{
    XSLogMethod2(@"xsHadAddMaterialListVXbuttonEvent")

    [self hide_HadAddMaterialListV];
    
    if(self.xsEditeDigitalRobotTitleVBgView.hidden==YES){
        //// CropTage 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
        //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
        [self xsHidenNotCurentRectViewWithCropTage:-1 withIsHiddenAllImageAndLabel:YES];
    }
    
}
//素材库添加被点击
- (void)xsHadAddMaterialPackAddbuttonbuttonEvent:(UIButton *)button{
    XSLogMethod2(@"xsHadAddMaterialPackAddbuttonbuttonEvent")

    [self hide_HadAddMaterialListV];
    
    
    if(self.RobotBottomView){
        NSLog(@"模拟素材被点击");
        
        [self xsMaterialIsHiden:NO];
        [_RobotBottomView xsChangeMaterialButtonIsClick:YES];
        [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(xsMoniMaterialBeClickEvent:) userInfo:nil repeats:NO];
    }
}
- (void)xsMoniMaterialBeClickEvent:(NSTimer *)sender{
    // 显示添加素材弹框
    [self show_SelectAddMaterialV];
}

#pragma mark 选中素材列表view end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -




#pragma mark - start  ⭐️⭐️⭐️⭐️⭐️
#pragma mark  调整层级view 对应的视图
- (void)show_BossIPChangeLevelVWithType:(xsEditeDigitalRobotType)Type{
    
    CGFloat xsBossIPChangeLevelBackGroundViewW = ScreenW;
    CGFloat xsBossIPChangeLevelBackGroundViewH = 160.0;
    CGFloat xsBossIPChangeLevelBackGroundViewX = 0;
    CGFloat xsBossIPChangeLevelBackGroundViewY = ScreenH;//-xsBossIPChangeLevelBackGroundViewH;
    CGFloat xsBossIPChangeLevelBackGroundViewY2 = ScreenH-xsBossIPChangeLevelBackGroundViewH;
    
    if(!_xsBossIPChangeLevelBackGroundView){
        [self.bgView addSubview:self.xsBossIPChangeLevelBackGroundView];
        self.xsBossIPChangeLevelBackGroundView.frame = CGRectMake(xsBossIPChangeLevelBackGroundViewX, xsBossIPChangeLevelBackGroundViewY, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
    }
    
    if(!_xsBossIPChangeLevelV){
        [self.xsBossIPChangeLevelBackGroundView addSubview:self.xsBossIPChangeLevelV];
        self.xsBossIPChangeLevelV.frame = CGRectMake(0, 0, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
        [self.xsBossIPChangeLevelV xsChangeFrame];
        
        XSWeakSelf;
        self.xsBossIPChangeLevelBackGroundView.alpha = 0.0;
        [UIView animateWithDuration:0.25 animations:^{
            weakSelf.xsBossIPChangeLevelBackGroundView.frame = CGRectMake(xsBossIPChangeLevelBackGroundViewX, xsBossIPChangeLevelBackGroundViewY2, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
            
            weakSelf.xsBossIPChangeLevelBackGroundView.alpha = 1.0;
        } completion:^(BOOL finished) {
            
        }];
    }
    
    if(self.xsBossIPChangeLevelBackGroundView.hidden==YES){
        self.xsBossIPChangeLevelBackGroundView.hidden = NO;
        //[self.bgView addSubview:self.xsBossIPChangeLevelBackGroundView];
        self.xsBossIPChangeLevelBackGroundView.frame = CGRectMake(xsBossIPChangeLevelBackGroundViewX, xsBossIPChangeLevelBackGroundViewY, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
        
        self.xsBossIPChangeLevelV.frame = CGRectMake(0, 0, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
        //[self.xsBossIPChangeLevelBackGroundView addSubview:self.DigitalRobotView];
        
        [self.xsBossIPChangeLevelV xsChangeFrame];
        
        XSWeakSelf;
        self.xsBossIPChangeLevelBackGroundView.alpha = 0.0;
        [UIView animateWithDuration:0.25 animations:^{
            weakSelf.xsBossIPChangeLevelBackGroundView.frame = CGRectMake(xsBossIPChangeLevelBackGroundViewX, xsBossIPChangeLevelBackGroundViewY2, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
            
            weakSelf.xsBossIPChangeLevelBackGroundView.alpha = 1.0;
        } completion:^(BOOL finished) {
            
        }];
    }
//    else{
//        
//    }
    
    [self.xsBossIPChangeLevelV bsChangeType:Type];
    
}



- (void)hide_BossIPChangeLevelV{
    
    CGFloat xsBossIPChangeLevelBackGroundViewW = ScreenW;
    CGFloat xsBossIPChangeLevelBackGroundViewH = 160.0;//400.0;
    CGFloat xsBossIPChangeLevelBackGroundViewX = 0;
    CGFloat xsBossIPChangeLevelBackGroundViewY = ScreenH;//-xsBossIPChangeLevelBackGroundViewH;
    //CGFloat xsBossIPChangeLevelBackGroundViewY2 = ScreenH-xsBossIPChangeLevelBackGroundViewH;
    
    XSWeakSelf;
    self.xsBossIPChangeLevelBackGroundView.alpha = 1.0;
    [UIView animateWithDuration:0.25 animations:^{
        weakSelf.xsBossIPChangeLevelBackGroundView.frame = CGRectMake(xsBossIPChangeLevelBackGroundViewX, xsBossIPChangeLevelBackGroundViewY, xsBossIPChangeLevelBackGroundViewW, xsBossIPChangeLevelBackGroundViewH);
        
        weakSelf.xsBossIPChangeLevelBackGroundView.alpha = 0.0;
    } completion:^(BOOL finished) {
        weakSelf.xsBossIPChangeLevelBackGroundView.hidden = YES;
    }];
}





#pragma mark xsBossIPChangeLevelViewProtoCol
- (void)xsBossIPChangeLevelBackbuttonEvent:(UIButton *)button{
    
    NSLog(@"xsBossIPChangeLevelBackbuttonEvent");
    
    [self hide_BossIPChangeLevelV];
    self.isToBigView = NO;
    [self bsShowDigitalRobotToBig:self.isToBigView];
}
#pragma mark 上移 移到最上 下移  移到最下
- (void)xsBossIPChangeLevelButtonItemBeClick:(UIButton *)button WithType:(xsEditeDigitalRobotType)RobotTyp{
    
    NSLog(@"xsBossIPChangeLevelButtonItemBeClick--button.tag==%ld\n",button.tag);
    
    //获取当前cropTg
    CGFloat currentCropTg = 0;
    if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
        xsCropBaseLabel *tempCropImageView = (xsCropBaseLabel *)self.recordUserDragView;
        currentCropTg = tempCropImageView.cropTag;
    }
    else if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
        xsCropBaseImageView *tempCropImageView = (xsCropBaseImageView *)self.recordUserDragView;
        currentCropTg = tempCropImageView.cropTag;
    }
    else if([self.recordUserDragView isKindOfClass:[xsCropBaseButton class]]){
        xsCropBaseButton *tempCropImageView = (xsCropBaseButton *)self.recordUserDragView;
        currentCropTg = tempCropImageView.cropTag;
    }
    else if([self.recordUserDragView isKindOfClass:[xsCropBaseView class]]){
        xsCropBaseView *tempCropImageView = (xsCropBaseView *)self.recordUserDragView;
        currentCropTg = tempCropImageView.cropTag;
    }
    
    xsCropBaseView *findMoveView;
    int findIndex = 0;
    for (int i=0;i<self.TestRobotCropCurrentMarray.count;i++) {
        xsCropBaseView *tempBaseView = self.TestRobotCropCurrentMarray[i];
        if(tempBaseView.cropTag==currentCropTg){
            findIndex = i;
            findMoveView = tempBaseView;
            break;
        }
    }
    
    if(!findMoveView){
        return;
    }
    
    xsCropBaseView *findCropView;
    for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
        xsCropBaseView *tempCropV = self.TestRobotCropViewMarray[i];
        if(tempCropV.cropTag==currentCropTg){
            findCropView = tempCropV;
            break;
        }
    }
    xsCropBaseButton *findDeleteButton;
    for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
        xsCropBaseButton *tempDeleteButton = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
        if(tempDeleteButton.cropTag==currentCropTg){
            findDeleteButton = tempDeleteButton;
            break;
        }
    }
    

    if(button.tag==0){//上移
        
        if(findIndex<(self.TestRobotCropCurrentMarray.count-2)){

            NSUInteger index1 = findIndex;
            NSUInteger index2 = findIndex+1;

            xsCropBaseView *tempBottom = [self.TestRobotCropCurrentMarray objectAtIndex:index1];
            xsCropBaseView *tempTop = [self.TestRobotCropCurrentMarray objectAtIndex:index2];
            [self.TestRobotCropCurrentMarray replaceObjectAtIndex:index1 withObject:tempTop];
            [self.TestRobotCropCurrentMarray replaceObjectAtIndex:index2 withObject:tempBottom];

            // 如果你有多个子视图，并且你想在特定子视图之间插入另一个子视图，你可以使用：
//             [self.topImgBgView insertSubview:someOtherSubview aboveSubview:subView1];
            // 或者
            // [self insertSubview:someOtherSubview belowSubview:subView2];
            [self.topImgBgView insertSubview:tempBottom aboveSubview:tempTop];
            if(findCropView){
                //[tempBottom bringSubviewToFront:tempBottom];
                [self.topImgBgView insertSubview:findCropView aboveSubview:tempBottom];
            }
            if(findDeleteButton){
                //[tempBottom bringSubviewToFront:findDeleteButton];
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:tempBottom];
            }
            if(findCropView&&findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:findCropView];
            }
            
            NSInteger tempTopCropTg = tempTop.cropTag;
            xsCropBaseView *tempTopCropView;
            for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
                xsCropBaseView *tempCropV2 = self.TestRobotCropViewMarray[i];
                if(tempCropV2.cropTag==tempTopCropTg){
                    tempTopCropView = tempCropV2;
                    break;
                }
            }
            xsCropBaseButton *tempTopDeleteButton;
            for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
                xsCropBaseButton *tempDeleteButton2 = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
                if(tempDeleteButton2.cropTag==tempTopCropTg){
                    tempTopDeleteButton = tempDeleteButton2;
                    break;
                }
            }
            if(tempTopCropView){
                [self.topImgBgView insertSubview:tempTopCropView aboveSubview:tempTop];
            }
            if(tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTop];
            }
            if(tempTopCropView&&tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTopCropView];
            }
        }
        else{
            NSLog(@"你已经是最上面了");
        }
    }
    else if(button.tag==1){// 移到最上
        
        if(findIndex<(self.TestRobotCropCurrentMarray.count-1)){
            
            
            xsCropBaseView *tempMovView = [self.TestRobotCropCurrentMarray objectAtIndex:findIndex];
            [self.TestRobotCropCurrentMarray removeObjectAtIndex:findIndex];
            xsCropBaseView *tempTopView = self.TestRobotCropCurrentMarray.lastObject;
            [self.TestRobotCropCurrentMarray addObject:tempMovView];
            
//            [A bringSubviewToFront:B]; B视图在A视图上面
//            [A sendSubviewToBack:B]; B视图在A视图下面
          
            [self.topImgBgView insertSubview:tempMovView aboveSubview:tempTopView];
            if(findCropView){
                [self.topImgBgView insertSubview:findCropView aboveSubview:tempMovView];
            }
            if(findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:tempMovView];
            }
            if(findCropView&&findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:findCropView];
            }
            
            NSInteger tempTopCropTg = tempTopView.cropTag;
            xsCropBaseView *tempTopCropView;
            for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
                xsCropBaseView *tempCropV2 = self.TestRobotCropViewMarray[i];
                if(tempCropV2.cropTag==tempTopCropTg){
                    tempTopCropView = tempCropV2;
                    break;
                }
            }
            xsCropBaseButton *tempTopDeleteButton;
            for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
                xsCropBaseButton *tempDeleteButton2 = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
                if(tempDeleteButton2.cropTag==tempTopCropTg){
                    tempTopDeleteButton = tempDeleteButton2;
                    break;
                }
            }
            if(tempTopCropView){
                [self.topImgBgView insertSubview:tempTopCropView aboveSubview:tempTopView];
            }
            if(tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTopView];
            }
            if(tempTopCropView&&tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTopCropView];
            }

        }
        else{
            NSLog(@"你已经是最上上上上面面了");
        }
        
    }
    else if(button.tag==2){//下移
        
        if(findIndex>=1){
            
            NSUInteger index1 = findIndex-1;
            NSUInteger index2 = findIndex;

            xsCropBaseView *tempBottom = [self.TestRobotCropCurrentMarray objectAtIndex:index1];
            xsCropBaseView *tempTop = [self.TestRobotCropCurrentMarray objectAtIndex:index2];
            [self.TestRobotCropCurrentMarray replaceObjectAtIndex:index1 withObject:tempTop];
            [self.TestRobotCropCurrentMarray replaceObjectAtIndex:index2 withObject:tempBottom];
            
            
            [self.topImgBgView insertSubview:tempBottom aboveSubview:tempTop];
            if(findCropView){
                [self.topImgBgView insertSubview:findCropView aboveSubview:tempTop];
            }
            if(findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:tempTop];
            }
            if(findCropView&&findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:findCropView];
            }
            
            
            
            NSInteger tempTopCropTg = tempBottom.cropTag;
            xsCropBaseView *tempTopCropView;
            for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
                xsCropBaseView *tempCropV2 = self.TestRobotCropViewMarray[i];
                if(tempCropV2.cropTag==tempTopCropTg){
                    tempTopCropView = tempCropV2;
                    break;
                }
            }
            xsCropBaseButton *tempTopDeleteButton;
            for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
                xsCropBaseButton *tempDeleteButton2 = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
                if(tempDeleteButton2.cropTag==tempTopCropTg){
                    tempTopDeleteButton = tempDeleteButton2;
                    break;
                }
            }
            if(tempTopCropView){
                [self.topImgBgView insertSubview:tempTopCropView aboveSubview:tempBottom];
            }
            if(tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempBottom];
            }
            if(tempTopCropView&&tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTopCropView];
            }
        }
        else{
            NSLog(@"你已经是最下面面了");
        }
        
    }
    else if(button.tag==3){//移到最下
        
        
        if(findIndex>0){
            
            xsCropBaseView *tempMovView = [self.TestRobotCropCurrentMarray objectAtIndex:findIndex];
            [self.TestRobotCropCurrentMarray removeObjectAtIndex:findIndex];
            xsCropBaseView *tempBottomView = self.TestRobotCropCurrentMarray.firstObject;
            [self.TestRobotCropCurrentMarray insertObject:tempMovView atIndex:0];
//            [A bringSubviewToFront:B]; B视图在A视图上面
//            [A sendSubviewToBack:B]; B视图在A视图下面
          
//            [self insertSubview:someOtherSubview belowSubview:subView2]
//            [self.topImgBgView insertSubview:tempTop aboveSubview:tempBottom];
            
            [self.topImgBgView insertSubview:tempMovView belowSubview:tempBottomView];
            if(findCropView){
                [self.topImgBgView insertSubview:findCropView aboveSubview:tempMovView];
            }
            if(findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:tempMovView];
            }
            if(findCropView&&findDeleteButton){
                [self.topImgBgView insertSubview:findDeleteButton aboveSubview:findCropView];
            }
            
            
            
            NSInteger tempTopCropTg = tempBottomView.cropTag;
            xsCropBaseView *tempTopCropView;
            for (int i=0;i<self.TestRobotCropViewMarray.count;i++) {
                xsCropBaseView *tempCropV2 = self.TestRobotCropViewMarray[i];
                if(tempCropV2.cropTag==tempTopCropTg){
                    tempTopCropView = tempCropV2;
                    break;
                }
            }
            xsCropBaseButton *tempTopDeleteButton;
            for (int i=0;i<self.TestRobotCropViewTopLeftDeleteButtonsMarray.count;i++) {
                xsCropBaseButton *tempDeleteButton2 = self.TestRobotCropViewTopLeftDeleteButtonsMarray[i];
                if(tempDeleteButton2.cropTag==tempTopCropTg){
                    tempTopDeleteButton = tempDeleteButton2;
                    break;
                }
            }
            if(tempTopCropView){
                [self.topImgBgView insertSubview:tempTopCropView aboveSubview:tempBottomView];
            }
            if(tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempBottomView];
            }
            if(tempTopCropView&&tempTopDeleteButton){
                [self.topImgBgView insertSubview:tempTopDeleteButton aboveSubview:tempTopCropView];
            }
        }
        else{
            NSLog(@"你已经是最下下下下下面面了");
        }
        
    }
}


- (xsBossIPChangeLevelView *)xsBossIPChangeLevelV{
    
    if(!_xsBossIPChangeLevelV){
        // musicType 0选择配音中的音频参数 2选择背景音中的音频参数
        _xsBossIPChangeLevelV = [[xsBossIPChangeLevelView alloc] initWithType:2];
        _xsBossIPChangeLevelV.delegate = self;
    }
    return _xsBossIPChangeLevelV;
}

- (UIView *)xsBossIPChangeLevelBackGroundView{
    if(!_xsBossIPChangeLevelBackGroundView){
        _xsBossIPChangeLevelBackGroundView = [[UIView alloc] init];
        _xsBossIPChangeLevelBackGroundView.backgroundColor = UIColor.clearColor;
    }
    return _xsBossIPChangeLevelBackGroundView;
}


#pragma mark  调整层级 view end  ⭐️⭐️⭐️⭐️⭐️
#pragma mark -


- (XSButton *)xsPreviewButton{// 预览
    if (!_xsPreviewButton) {
        _xsPreviewButton = [XSButton buttonWithType:UIButtonTypeCustom];
        _xsPreviewButton.backgroundColor = COLOR_HEX(0x212333);
        _xsPreviewButton.titleLabel.font = Font(16);
        [_xsPreviewButton setTitleColor:COLOR_textWhiteColor forState:UIControlStateNormal];
        [_xsPreviewButton addTarget:self action:@selector(xsPreviewButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [_xsPreviewButton setTitle:@"预览" forState:UIControlStateNormal];
        _xsPreviewButton.layer.cornerRadius = 6.0;
        _xsPreviewButton.layer.masksToBounds = YES;
    }
    return _xsPreviewButton;
}
- (void)xsPreviewButtonAction:(UIButton *)btn{
    XSLog(@"xsPreviewButtonAction\n\n");
    
//    if(self.xsPreviewCallbackBlock){
//        self.xsPreviewCallbackBlock(btn);
//    }
    
    //生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
    self.xsNumberRobot_buildType = @"1";
    [self xsPreviewNumberRobotDataWithBuildType:1];
}

- (UILabel *)xsExportButtonLabel {
    if (!_xsExportButtonLabel) {
        _xsExportButtonLabel = [[UILabel alloc] init];
        _xsExportButtonLabel.backgroundColor = UIColor.clearColor;
        _xsExportButtonLabel.font = Font(16);
        _xsExportButtonLabel.textColor = COLOR_textWhiteColor;
        _xsExportButtonLabel.numberOfLines = 1;
        _xsExportButtonLabel.text = kLocalizedString(@"导出");
        _xsExportButtonLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _xsExportButtonLabel;
}
- (XSButton *)xsExportButton{// 导出
    if (!_xsExportButton) {
        _xsExportButton = [XSButton buttonWithType:UIButtonTypeCustom];
        _xsExportButton.backgroundColor = COLOR_Blue;
//        _xsExportButton.titleLabel.font = Font(16);
//        [_xsExportButton setTitleColor:COLOR_textWhiteColor forState:UIControlStateNormal];
        [_xsExportButton addTarget:self action:@selector(xsExportButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//        [_xsExportButton setTitle:@"导出" forState:UIControlStateNormal];
        
    }
    return _xsExportButton;
}

- (void)xsExportButtonAction:(UIButton *)btn{
    XSLog(@"xsExportButtonAction\n\n");
    
    //生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
    self.xsNumberRobot_buildType = @"2";
    
    [self xsPreviewNumberRobotDataWithBuildType:2];
    
//    if(self.xsExportCallbackBlock){
//        self.xsExportCallbackBlock(btn);
//    }
    
    //        dispatch_async(dispatch_get_main_queue(), ^{
    //
    //            UIImage *tempImg3 = [UIImage xsConvertViewRegionToImage:weakSelf.topImgBgView region:weakSelf.recordUserDragView.frame];
    //
    //
    //            UIImageView *tempImgV3 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, tempImg3.size.width, tempImg3.size.height)];
    //            tempImgV3.image = tempImg3;
    //            [weakSelf.view addSubview:tempImgV3];
    //
    //
    //            int a = 20;
    //        });
}
- (UIButton *)xsBackButton{
    
    if(!_xsBackButton){
        _xsBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _xsBackButton.backgroundColor = UIColor.blackColor;
        [_xsBackButton setImage:[UIImage imageNamed:@"wqicon_nav_back_light"] forState:UIControlStateNormal];
//        [_xsBackButton setImage:[UIImage imageNamed:@"wqicon_nav_back_light"] forState:UIControlStateSelected];
        [_xsBackButton setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
        //        [_xsBackButton layoutButtonWithEdgeInsetsStyle:XSButtonEdgeInsetsStyleImageLeft imageTitleSpace:8.0];
        [_xsBackButton addTarget:self action:@selector(xsBackButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _xsBackButton;
}

- (void)xsBackButtonClicked:(UIButton *)sender{
    
    
    NSLog(@"xsBackButtonClicked");
// [self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"1"}} domChanges:nil];
}


#pragma mark 播放配音音频
- (void)playConfigurationAudioFromURL:(NSURL *)url withRate:(float)rat withVolume:(float)volum {
  
//    // 创建AVPlayer对象
//    NSURL *url = [NSURL URLWithString:@"http://www.example.com/audio.mp3"]; // 音频文件网址
    
//    self.xsAudioVolumeNumberF;
//    self.xsLanguageSpeedNumberF;
    
    if(_ConfigurationBossPlayer){
        [_ConfigurationBossPlayer pause];
        _ConfigurationBossPlayer =nil;
        _ConfigurationBossPlayer = [[AVPlayer alloc] initWithURL:url];
    }
    else{
        _ConfigurationBossPlayer = [[AVPlayer alloc] initWithURL:url];
    }
    
    // 播放音频
 [_ConfigurationBossPlayer play];
    
    
    // 设置音量（0.0到1.0之间）
    _ConfigurationBossPlayer.volume = volum/100.0;
    // 设置播放速度（正数表示加速，负数表示减速）
    _ConfigurationBossPlayer.rate = rat;
    
    NSLog(@"playConfigurationAudioFromURL.volume==%f\n",volum/100.0);
    NSLog(@"playConfigurationAudioFromURL.rat==%f\n",rat);
    
   
}
#pragma mark 改变播放配音音频的 音量大小 语速快慢
- (void)xsChangeConfigurationPlayAudioWithRate:(float)rat withVolume:(float)volum{
    
    if(_ConfigurationBossPlayer){
        
        NSLog(@"_ConfigurationBossPlayer.volume==%f\n",volum/100.0);
        NSLog(@"_ConfigurationBossPlayer.rat==%f\n",rat);
        
        _ConfigurationBossPlayer.volume = volum/100.0;
        // 设置播放速度（正数表示加速，负数表示减速）
        _ConfigurationBossPlayer.rate = rat;
    }
}
#pragma mark 停止播放配音音频
- (void)xsStopConfigurationAudioMisicPlay{
    
    //    // 停止播放并释放资源
    [_ConfigurationBossPlayer pause];
    _ConfigurationBossPlayer = nil;
    NSLog(@"xsStopAudioMisicPlay");
}





#pragma mark 获取我的 官方 配音连接
// audioType;// 0我的 1官方
- (void)getAudioDataWithAudioType:(NSInteger)audioTyp
{
    //self.xsConfigurationMusicCollectionViewCellMd;
    
    XSWeakSelf;

    NSString *tempUrl = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"speech/createTestAudioByTemplate"];

    
    NSDictionary *pramerDict = @{
        @"rate":[NSString stringWithFormat:@"%.1f",self.xsLanguageSpeedNumberF],
        @"volume":[NSString stringWithFormat:@"%ld",(NSInteger)self.xsAudioVolumeNumberF],
        @"voiceTemplateId":[NSString stringWithFormat:@"%ld",self.xsConfigurationMusicCollectionViewCellMd.Id],
    };
    
//    [[XLNetWorkManager shareInstance] POSTBody:tempUrl withContentType:@"application/json" parameters:pramerDict success:^(id  _Nonnull responseObject) {
//        
//        NSDictionary *tempDict = responseObject;
//        
//        NSLog(@"pramerDict22===%@\n",pramerDict);
//        NSLog(@"tempUrl22===%@\n",tempUrl);
//        
//        NSLog(@"tempDict22===%@\n",tempDict);
//        
//    } failure:^(NSError * _Nonnull error) {
//        NSLog(@"XLNetWorkManager22--error.description==%@\n",error.description);
//    }];

    [MBProgressHUD showMessage:kLocalizedString(@"音频加载中...")];
    [[ZYFDataManager sharedInstance] POST:tempUrl dict:pramerDict succeed:^(id data) {
        
        
        NSDictionary *tempDict = data;
        
        NSLog(@"pramerDict===%@\n",pramerDict);
        NSLog(@"tempUrl===%@\n",tempUrl);
        
        NSLog(@"tempDict===%@\n",tempDict);
        if(tempDict&&[tempDict isKindOfClass:[NSDictionary class]]){
            
            NSInteger codeInt = [tempDict[@"code"] integerValue];
            if(codeInt==200){
                NSString *resDataStr = tempDict[@"data"];
                if(!kStringIsEmpty(resDataStr)){
//                    if(audioTyp==0){
//                        // audioType;// 0我的 1官方
//                    }
//                    else if(audioTyp==1){
//                        // audioType;// 0我的 1官方
//                    }
                    
                    
                    // 这个是记录选中的配音
                    self.xsConfigurationMusicCollectionViewCellMd.previewVoice = resDataStr;
                    
                    //audioType;// 0我的 1官方
                    if(audioTyp==0){
                       
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf playConfigurationAudioFromURL:[NSURL URLWithString:weakSelf.xsConfigurationMusicCollectionViewCellMd.previewVoice] withRate:weakSelf.xsLanguageSpeedNumberF withVolume:weakSelf.xsAudioVolumeNumberF];
                        });
                    }
                    else if(audioTyp==1){
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf playConfigurationAudioFromURL:[NSURL URLWithString:weakSelf.xsConfigurationMusicCollectionViewCellMd.previewVoice] withRate:weakSelf.xsLanguageSpeedNumberF withVolume:weakSelf.xsAudioVolumeNumberF];
                        });
                    }
                }
                else{
                    NSString *message = tempDict[@"message"];
                    if(notNillStr(message)){
                    }else{
                        message = tempDict[@"msg"];
                    }
                    if(kStringIsEmpty(message)){
                        message = @"音频加载失败!!";
                    }
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [MBProgressHUD showError:message];
                    });
                }
            }
            else{
                
            
                NSString *message = tempDict[@"message"];
                if(notNillStr(message)){
                }else{
                    message = tempDict[@"msg"];
                }
                if(kStringIsEmpty(message)){
                    message = @"音频加载失败!!";
                }
                dispatch_async(dispatch_get_main_queue(), ^{
                    [MBProgressHUD showError:message];
                });
            }
            
        }
        else{
            dispatch_async(dispatch_get_main_queue(), ^{
                [MBProgressHUD showError:kLocalizedString(@"音频加载失败!!")];
            });
        }
        
        
        
    } failure:^(NSDictionary *error) {
        NSLog(@"getAudioDataWithAspectRatio--error.description==%@\n",error.description);
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD showError:[NSString stringWithFormat:@"%@",error.description]];
        });
    }];
//    [[ZYFDataManager sharedInstance] POST:@"https://mall219.writemall.com/bossapi/speech/voiceTemplateList" dict:pramerDict succeed:^(id data) {} failure:^(NSDictionary *error) {}];
}

#pragma mark 预览-导出 数字人 🇨🇳🇨🇳🇨🇳🇨🇳🇨🇳🇨🇳🇨🇳🇨🇳🇨🇳
// buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
- (void)xsPreviewNumberRobotDataWithBuildType:(NSInteger)buildTypeInt
{
    //self.xsConfigurationMusicCollectionViewCellMd;
    
//    XSWeakSelf;

    NSString *tempUrl = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"digitalHuman/createTask"];

    
//    self.xsNumberRobot_buildType = @"1";
//    self.xsNumberRobot_aspectRatio = @"1";
//    self.xsNumberRobot_smartHighlightingEnabled = @"0";
//    self.xsNumberRobot_width = 200.0;
//    self.xsNumberRobot_height = 270.0;
    
    //背景图片地址 背景颜色
    if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)&&kStringIsEmpty(self.xsNumberRobot_backgroundColor)){
        [MBProgressHUD showError:kLocalizedString(@"请先选择背景图片或背景颜色")];
        return;
    }
    
//if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)){
//
//    [MBProgressHUD showError:kLocalizedString(@"请先选择背景图片")];
//    return;
//
////        xsNumberRobot_digitalHumanStyle
//}
    //背景图片地址
//    weakSelf.xsNumberRobot_backgroundImageUrl = [cbModel.previewImage copy];
    
    
    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕
    //@property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
    xsCropBaseImageView *tempFindCropImg;
    for (xsCropBaseImageView *tempCropImg in self.TestRobotCropCurrentMarray) {
        if(tempCropImg.cropTag==0){
            
            tempFindCropImg = tempCropImg;
            break;
        }
    }
    
    // 获取子视图在父视图中的坐标
    CGPoint digitalHumanStyleIntopImgBgViewLocation = [tempFindCropImg convertPoint:CGPointZero toView:self.topImgBgView];
    //NSLog(@"子视图在父视图中的位置1： (%f, %f)", childViewPositionInParentView.x, childViewPositionInParentView.y);
                                          //self.bossBackgroundImage
    CGPoint xsbossBackgroundImagePoint = [self.bossBackgroundImage convertPoint:CGPointZero toView:self.topImgBgView];
   // NSLog(@"子视图在父视图中的位置2： (%f, %f)", xsbossBackgroundImagePoint.x, xsbossBackgroundImagePoint.y);
    
    CGFloat digitalHumanStyleX = digitalHumanStyleIntopImgBgViewLocation.x - xsbossBackgroundImagePoint.x;
    CGFloat digitalHumanStyleY = digitalHumanStyleIntopImgBgViewLocation.y - xsbossBackgroundImagePoint.y;
    NSLog(@"digitalHumanStyleX-Y： (%f, %f)", digitalHumanStyleX, digitalHumanStyleY);

    NSLog(@"self.bossBackgroundImage在topImgBgView中的位置: (%f, %f)", self.bossBackgroundImage.origin.x, self.bossBackgroundImage.origin.y);
    
//    CGPoint childViewPositionInParentView2 = [tempFindCropImg convertPoint:CGPointZero toView:self.bossBackgroundImage];
//    NSLog(@"子视图在父视图中的位置5： (%f, %f)", childViewPositionInParentView2.x, childViewPositionInParentView2.y);
    
//    CGFloat tempFindCropImgX = childViewPositionInParentView.x;
//    CGFloat tempFindCropImgY = ;
//            width: 1080.0,
//            height: 1920.0,
    CGFloat ratio = 1080.0 / self.bossBackgroundImage.width;
    CGFloat ratioY = 1920.0 / self.bossBackgroundImage.height;
    
    if(!kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)){
        
        CGFloat graphicalObjectX = 0.0;// [[NSString stringWithFormat:@"%.2f",digitalHumanStyleX*ratio] doubleValue];
        CGFloat graphicalObjectY = 0.0;//[[NSString stringWithFormat:@"%.2f",digitalHumanStyleY*ratioY] doubleValue];
        CGFloat graphicalObjectW = [[NSString stringWithFormat:@"%.2f",self.bossBackgroundImage.width*ratio] doubleValue];
        CGFloat graphicalObjectH = [[NSString stringWithFormat:@"%.2f",self.bossBackgroundImage.height*ratioY] doubleValue];
        NSDictionary *graphicalObjectDict = @{@"path":[self.xsNumberRobot_backgroundImageUrl copy],
                                   @"order":@(1),
                                   @"x":@(graphicalObjectX),
                                   @"y":@(graphicalObjectY),
                                   @"width":@(graphicalObjectW),
                                   @"height":@(graphicalObjectH)};
        
        self.xsNumberRobot_graphicalObjects =@[graphicalObjectDict];
    }
    else{
        self.xsNumberRobot_graphicalObjects = @[];
    }
    
    //NSString *xsdigitalHumanStyleStr = [NSString convertToJsonData:Mdddict];
    
    
    if(_RobotBottomView){
        if(_RobotBottomView.xsTitleButton.selected){
            //标题
            if(kStringIsEmpty(self.xsNumberRobot_title)){
                [MBProgressHUD showError:kLocalizedString(@"请先填写标题")];
                return;
            }
        }
        else{
            self.xsNumberRobot_title = @"";
        }
    }
    else{
        self.xsNumberRobot_title = @"";
    }
    
    self.xsNumberRobot_text = [self.RobotBottomView xsGetInputCopywritingText];
    //视频（字幕）内容
    if(kStringIsEmpty(self.xsNumberRobot_text)){
        [MBProgressHUD showError:kLocalizedString(@"请先填写视频（字幕）内容")];
        return;
    }
    
    
    //背景音乐id
    if(kStringIsEmpty(self.xsNumberRobot_musicId)){
        [MBProgressHUD showError:kLocalizedString(@"请先选择背景音乐")];
        return;
    }
    
    
    //数字人id
    if(kStringIsEmpty(self.xsNumberRobot_digitalHumanId)){
        [MBProgressHUD showError:kLocalizedString(@"请先选择数字人")];
        return;
    }
    
    
   

//    //语音模板id
//    if(kStringIsEmpty(self.xsNumberRobot_voiceTemplateId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择语音模板")];
//        return;
//    }
//
//    //数字人声音id
//    if(kStringIsEmpty(self.xsNumberRobot_digitalHumanVoiceId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择数字人声音")];
//        return;
//    }
    
    if(!self.xsConfigurationMusicCollectionViewCellMd){
        
        [MBProgressHUD showError:kLocalizedString(@"请先选择配音")];
        return;
    }
    
    
    
    if(_RobotBottomView){
        if(_RobotBottomView.xsMaterialButton.selected){
            //素材列表
            if(self.xsSelectAddMaterialModelMarray.count<=0){
                [MBProgressHUD showError:kLocalizedString(@"请先选择素材")];
                return;
            }
        }
    }
    
    
    
//    //素材列表
//    if(self.xsNumberRobot_materials.count<=0){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择素材")];
//        return;
//    }
    
//    type    素材类型 1.图片 2.视频        false integer(int32)
//    path    文件地址     false string
    NSMutableArray *tempMaterialsMarr = [[NSMutableArray alloc] initWithCapacity:self.xsSelectAddMaterialModelMarray.count];
    
        for (xsSelectAddMaterialCollectionViewCellModel *findSelectItemModel in self.xsSelectAddMaterialModelMarray) {
            NSString *xsMaterialFileUrl = findSelectItemModel.url;
            if(kStringIsEmpty(xsMaterialFileUrl)){
                xsMaterialFileUrl = [NSString new];
            }
            NSString *xsMaterialType=@"1";
            if([xsMaterialFileUrl containsString:@".mp4"]){
                xsMaterialType = @"2";
            }
            NSDictionary *tempMaterialDict = @{@"type":xsMaterialType,@"path":xsMaterialFileUrl};
            [tempMaterialsMarr addObject:tempMaterialDict];
        }
    
    self.xsNumberRobot_materials = [NSArray arrayWithArray:tempMaterialsMarr];
    
    
    if(!self.xsNumberRobot_materials){
        self.xsNumberRobot_materials = [NSArray new];
    }
    
    //xsNumberRobot_textObjects
    // 获取普通文本列表
    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕 4及以上为普通文本
    //@property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
    NSMutableArray *textObjectsMarray = [[NSMutableArray alloc] init];
    for (xsCropBaseLabel *tempCropLabel3 in self.TestRobotCropCurrentMarray) {
        // 普通文本 和字幕
        if(tempCropLabel3.cropTag>=3){// 普通文本
            
            // 普通文本
            if(tempCropLabel3.cropTag>3){// 普通文本
                // 获取子视图在父视图中的坐标
                CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
                
                CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
                CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
                
                NSLog(@"文本的位置tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f",tempCropLabel3X,tempCropLabel3Y);
                NSString *contentStr = [NSString stringWithFormat:@"%@",tempCropLabel3.recodeBaseStr];
                NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
                NSString *typeStr = @"0";//文本类型 0普通文本 1字幕 2标题
                //x轴位置 单位px 视频左上角为原点
                NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X*ratio];
                //y轴位置 单位px 视频左上角为原点
                NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y*ratioY];
                NSString *fontSizeStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3.xsTextSizeF];//*ratio
                NSString *fontNameStr;// = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                if(!kStringIsEmpty(tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer)){
                    fontNameStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                }
                else{
                    fontNameStr = [NSString new];
                }
                NSString *primaryColourStr;
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.primaryColour)){
                    primaryColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.primaryColour];
                }
                else{
                    primaryColourStr = [NSString new];
                }
                NSString *outlineColourStr;
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                    outlineColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.outlineColour];
                }
                else{
                    outlineColourStr = [NSString new];
                }
                NSString *outlineStr = [NSString stringWithFormat:@"%@",@"0"];
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                    outlineStr = @"1";
                }
                
               NSDictionary *tempTextDict = @{@"content":contentStr,
                                              @"order":@([orderStr integerValue]+2),
                                              @"type":@([typeStr intValue]),//文本类型 0普通文本 1字幕 2标题
                                              @"marginL":@([marginLStr doubleValue]),
                                              @"marginV":@([marginVStr doubleValue]),
                                              @"fontSize":@([fontSizeStr intValue]),
                                              @"fontName":fontNameStr,
                                              @"primaryColour":primaryColourStr,
                                              @"outlineColour":outlineColourStr,
                                              @"outline":@([outlineStr intValue])};
                
                [textObjectsMarray addObject:tempTextDict];
            }
            //字幕
            else{//字幕 这里cropTag==3
                
                // 获取子视图在父视图中的坐标
                CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
                
                CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
                CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
                
                NSLog(@"文本的位置tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f",tempCropLabel3X,tempCropLabel3Y);
                //type    文本类型 0普通文本 1字幕 2标题
                NSString *contentStr = [NSString stringWithFormat:@"%@",tempCropLabel3.recodeBaseStr];
                NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
                NSString *typeStr = @"0";
                if(tempCropLabel3.cropTag==3){
                    typeStr = @"1";
                }
                //x轴位置 单位px 视频左上角为原点
                NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X*ratio];
                //y轴位置 单位px 视频左上角为原点
                NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y*ratioY];
                NSString *fontSizeStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3.xsTextSizeF];//*ratio
                NSString *fontNameStr;// = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                if(!kStringIsEmpty(tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer)){
                    fontNameStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                }
                else{
                    fontNameStr = [NSString new];
                }
                NSString *primaryColourStr;
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.primaryColour)){
                    primaryColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.primaryColour];
                }
                else{
                    primaryColourStr = [NSString new];
                }
                NSString *outlineColourStr;
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                    outlineColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.outlineColour];
                }
                else{
                    outlineColourStr = [NSString new];
                }
                NSString *outlineStr = [NSString stringWithFormat:@"%@",@"0"];
                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                    outlineStr = @"1";
                }
                
               NSDictionary *tempTextDict = @{@"content":contentStr,
                                              @"order":@([orderStr integerValue]+2),
                                              @"type":@(1),//文本类型 0普通文本 1字幕 2标题
                                              @"marginL":@([marginLStr doubleValue]),
                                              @"marginV":@([marginVStr doubleValue]),
                                              @"fontSize":@([fontSizeStr intValue]),
                                              @"fontName":fontNameStr,
                                              @"primaryColour":primaryColourStr,
                                              @"outlineColour":outlineColourStr,
                                              @"outline":@([outlineStr intValue])};
                
                self.xsNumberRobot_assStyle = tempTextDict;
            }
            
        }
        else{
            
            // 标题
            if(tempCropLabel3.cropTag==2){// 标题
                
                
                if(_RobotBottomView){
                    if(_RobotBottomView.xsTitleButton.selected){
                        //标题
//                        if(kStringIsEmpty(self.xsNumberRobot_title)){
//                            [MBProgressHUD showError:kLocalizedString(@"请先填写标题")];
//                            return;
//                        }
                        // 获取子视图在父视图中的坐标
                        CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
                        
                        CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
                        CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
                        
                        NSLog(@"文本的位置tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f",tempCropLabel3X,tempCropLabel3Y);
                        //type    文本类型 0普通文本 1字幕 2标题
                        NSString *contentStr = [NSString stringWithFormat:@"%@",tempCropLabel3.recodeBaseStr];
                        NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
                        NSString *typeStr = @"2";
                        //x轴位置 单位px 视频左上角为原点
                        NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X*ratio];
                        //y轴位置 单位px 视频左上角为原点
                        NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y*ratioY];
                        NSString *fontSizeStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3.xsTextSizeF];//*ratio
                        NSString *fontNameStr;// = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                        if(!kStringIsEmpty(tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer)){
                            fontNameStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
                        }
                        else{
                            fontNameStr = [NSString new];
                        }
                        NSString *primaryColourStr;
                        if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.primaryColour)){
                            primaryColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.primaryColour];
                        }
                        else{
                            primaryColourStr = [NSString new];
                        }
                        NSString *outlineColourStr;
                        if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                            outlineColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.outlineColour];
                        }
                        else{
                            outlineColourStr = [NSString new];
                        }
                        NSString *outlineStr = [NSString stringWithFormat:@"%@",@"0"];
                        if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
                            outlineStr = @"1";
                        }
                        
                       NSDictionary *tempTextDict = @{@"content":contentStr,
                                                      @"order":@([orderStr integerValue]+2),
                                                      @"type":@([typeStr intValue]),
                                                      @"marginL":@([marginLStr doubleValue]),
                                                      @"marginV":@([marginVStr doubleValue]),
                                                      @"fontSize":@([fontSizeStr intValue]),
                                                      @"fontName":fontNameStr,
                                                      @"primaryColour":primaryColourStr,
                                                      @"outlineColour":outlineColourStr,
                                                      @"outline":@([outlineStr intValue])};
                        
                        self.xsNumberRobot_titleStyle = tempTextDict;
                    }
                    else{
                        NSDictionary *tempTextDict = [NSDictionary new];
                        self.xsNumberRobot_titleStyle = tempTextDict;
                    }
                }
                else{
                    NSDictionary *tempTextDict = [NSDictionary new];
                    self.xsNumberRobot_titleStyle = tempTextDict;
                }
                
                
            }
            // 素材
            else if(tempCropLabel3.cropTag==1){// 素材
                
                
                if(_RobotBottomView){
                    if(_RobotBottomView.xsMaterialButton.selected){
                        //素材列表
//                        if(self.xsSelectAddMaterialModelMarray.count<=0){
//                            [MBProgressHUD showError:kLocalizedString(@"请先选择素材")];
//                            return;
//                        }
                        xsCropBaseImageView *suChaiCropImageView = (xsCropBaseImageView *)tempCropLabel3;
                        
                       CGSize suChaiCropImageViewSize = [YSHelp bossIPGetImageCompressedSizeWithImageView:suChaiCropImageView];
                        
                        NSLog(@"图片压缩后的大小--suChaiCropImageViewSize==%@\n",NSStringFromCGSize(suChaiCropImageViewSize));
                        
                        CGFloat imageBoxW = tempCropLabel3.width;
                        CGFloat imageBoxH = tempCropLabel3.height;

                        //获取frame  16:9最佳宽高
                        CGFloat loveW9img  = 9.0;
                        CGFloat loveH16img = 16.0;
        //                BOOL xsIsBrek = NO;
        //                CGFloat count = 1.0;
        //                while (!xsIsBrek) {
        //
        //                    CGFloat tempimageBoxW9 = loveW9img *count;
        //                    CGFloat tempimageBoxH16 = loveH16img *count;
        //
        //                    if(count==21){
        //                        NSLog(@"tempimageBoxW9==%f\n",tempimageBoxW9);
        //                        NSLog(@"tempimageBoxH16==%f\n",tempimageBoxH16);
        //                    }
        //                    if((tempimageBoxW9<=imageBoxW)&&(tempimageBoxH16<=imageBoxH)){
        //                        //count++;
        //                        count = count+0.01;
        //                    }
        //                    else{
        //                        xsIsBrek = YES;
        //                    }
        //                    NSLog(@"loveW9img==%f\n",loveW9img);
        //                    NSLog(@"loveH16img==%f\n",loveH16img);
        //                }
        //                //count = count-1;
        //                count = count-0.01;
        //
        //                loveW9img = loveW9img *count;
        //                loveH16img = loveH16img *count;
                        
                        loveW9img = suChaiCropImageViewSize.width;
                        loveH16img = suChaiCropImageViewSize.height;
                        
                        // 获取子视图在父视图中的坐标
                        CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
                        //self.bossBackgroundImage;
                        
                        CGFloat imgLeftMargin = (tempCropLabel3.width-loveW9img)*0.5;
                        CGFloat imgTopMargin = (tempCropLabel3.height-loveH16img)*0.5;
                        
                        CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
                        CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
                        
                        tempCropLabel3X = tempCropLabel3X + imgLeftMargin;
                        tempCropLabel3Y = tempCropLabel3Y + imgTopMargin;
                        
                        
                        
                        
                        NSLog(@"素材的位置大小tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f loveW9img==%f   loveH16img==%f\n",tempCropLabel3X,tempCropLabel3Y,loveW9img,loveH16img);
                        //type    文本类型 0普通文本 1字幕 2标题
                        NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
                        
                        //x轴位置 单位px 视频左上角为原点
                        NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X*ratio];
                        //y轴位置 单位px 视频左上角为原点
                        NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y*ratioY];
                        
                        NSString * materialStyleW = [NSString stringWithFormat:@"%.2f",loveW9img*ratio];
                        NSString * materialStyleH = [NSString stringWithFormat:@"%.2f",loveH16img*ratioY];
                       NSDictionary *tempTextDict = @{
                                                      @"order":@([orderStr integerValue]+2),
                                                      @"x":@([marginLStr doubleValue]),
                                                      @"y":@([marginVStr doubleValue]),
        //                                              @"width":@(tempCropLabel3.width*ratio),
        //                                              @"height":@(tempCropLabel3.height*ratio)
                                                      @"width":@([materialStyleW doubleValue]),
                                                      @"height":@([materialStyleH doubleValue])
                       };
                        
                        self.xsNumberRobot_materialStyle = tempTextDict;
                    }
                    else{
                        
                        NSDictionary *tempTextDict = [NSDictionary new];
                        self.xsNumberRobot_materialStyle = tempTextDict;
                    }
                }
                else{
                    NSDictionary *tempTextDict = [NSDictionary new];
                    self.xsNumberRobot_materialStyle = tempTextDict;
                }
                
                
            }
            // 数字人(说话的那个人)
            else if(tempCropLabel3.cropTag==0){// 数字人(说话的那个人)
                
                xsCropBaseImageView *tempCropImage0 = (xsCropBaseImageView *)tempCropLabel3;
                // 获取子视图在父视图中的坐标
                CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
                
                
                
                
                CGFloat imageBoxW = tempCropLabel3.width;
                CGFloat imageBoxH = tempCropLabel3.height;
                
                
                
                
                
                //获取frame  16:9最佳宽高
                CGFloat loveW9img  = 9.0;
                CGFloat loveH16img = 16.0;
                BOOL xsIsBrek = NO;
                CGFloat count = 1.0;
                while (!xsIsBrek) {
                        
                    CGFloat tempimageBoxW9 = loveW9img *count;
                    CGFloat tempimageBoxH16 = loveH16img *count;
                    
                    if(count==21){
                        NSLog(@"tempimageBoxW9==%f\n",tempimageBoxW9);
                        NSLog(@"tempimageBoxH16==%f\n",tempimageBoxH16);
                    }
                    if((tempimageBoxW9<=imageBoxW)&&(tempimageBoxH16<=imageBoxH)){
                        //count++;
                        count = count+0.01;
                    }
                    else{
                        xsIsBrek = YES;
                    }
                    NSLog(@"loveW9img==%f\n",loveW9img);
                    NSLog(@"loveH16img==%f\n",loveH16img);
                }
                //count = count-1;
                count = count-0.01;
                
                loveW9img = loveW9img *count;
                loveH16img = loveH16img *count;
                
            
                //self.bossBackgroundImage;
                
                CGFloat imgLeftMargin = (tempCropLabel3.width-loveW9img)*0.5;
                CGFloat imgTopMargin = (tempCropLabel3.height-loveH16img)*0.5;
                
                CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
                CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
                
                tempCropLabel3X = tempCropLabel3X + imgLeftMargin;
                tempCropLabel3Y = tempCropLabel3Y + imgTopMargin;
                
                NSLog(@"数字人的位置大小tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f loveW9img==%f   loveH16img==%f\n",tempCropLabel3X,tempCropLabel3Y,loveW9img,loveH16img);
                
                
                //type    文本类型 0普通文本 1字幕 2标题
                NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
                
                //x轴位置 单位px 视频左上角为原点
                NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X*ratio];
                //y轴位置 单位px 视频左上角为原点
                NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y*ratioY];
                
                
                NSString * digitalHumanStyW = [NSString stringWithFormat:@"%.2f",loveW9img*ratio];
                NSString * digitalHumanStyH = [NSString stringWithFormat:@"%.2f",loveH16img*ratioY];
                
               NSDictionary *tempTextDict = @{
                                              @"order":@([orderStr integerValue]+2),
                                              @"path":tempCropImage0.digitalHumanIdImageUrl,
                                              @"x":@([marginLStr doubleValue]),
                                              @"y":@([marginVStr doubleValue]),
//                                              @"width":@(tempCropLabel3.width*ratio),
//                                              @"height":@(tempCropLabel3.height*ratio)
                                              @"width":@([digitalHumanStyW doubleValue]),
                                              @"height":@([digitalHumanStyH doubleValue])
               };
                     
                self.xsNumberRobot_digitalHumanStyle = tempTextDict;
            }
        }
    }
    self.xsNumberRobot_textObjects = [NSArray arrayWithArray:textObjectsMarray];
    
    NSDictionary *pramerDict;
    
    if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)){
        
        
        //audioType;// 0我的 1官方
        if(self.xsConfigurationMusicCollectionViewCellMd.audioType==0){
            // 我的 xsNumberRobot_digitalHumanVoiceId
            pramerDict = @{
                @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
                @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
                @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
                //1080.0 1920.0
    //            @"width":@(self.xsNumberRobot_width),//视频宽度
    //            @"height":@(self.xsNumberRobot_height),//视频高度
                @"width":@(1080.0),//视频宽度
                @"height":@(1920.0),//视频高度
    //            @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
                @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
                @"title":self.xsNumberRobot_title,//标题
                @"text":self.xsNumberRobot_text,//视频（字幕）内容
                @"musicId":self.xsNumberRobot_musicId,//背景音乐id
                @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
                @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
                @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
                @"materials":self.xsNumberRobot_materials,//素材列表
                
                @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
                //@"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
                @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
               
                //graphicalObjects 背景图片位置及路径大小
                @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
                @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
        //
                @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
                @"titleStyle":self.xsNumberRobot_titleStyle,
                @"materialStyle":self.xsNumberRobot_materialStyle,
                @"assStyle":self.xsNumberRobot_assStyle,//
        
                
                
                
            };
        }
        else{
            // 官方 xsNumberRobot_voiceTemplateId
            
            pramerDict = @{
                @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
                @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
                @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
                //1080.0 1920.0
    //            @"width":@(self.xsNumberRobot_width),//视频宽度
    //            @"height":@(self.xsNumberRobot_height),//视频高度
                @"width":@(1080.0),//视频宽度
                @"height":@(1920.0),//视频高度
    //            @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
                @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
                @"title":self.xsNumberRobot_title,//标题
                @"text":self.xsNumberRobot_text,//视频（字幕）内容
                @"musicId":self.xsNumberRobot_musicId,//背景音乐id
                @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
                @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
                @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
                @"materials":self.xsNumberRobot_materials,//素材列表
                
                @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
                @"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
//                @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
               
                //graphicalObjects 背景图片位置及路径大小
                @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
                @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
        //
                @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
                @"titleStyle":self.xsNumberRobot_titleStyle,
                @"materialStyle":self.xsNumberRobot_materialStyle,
                @"assStyle":self.xsNumberRobot_assStyle,//
        
                
                
                
            };
        }
    }
    else{
        
        //audioType;// 0我的 1官方
        if(self.xsConfigurationMusicCollectionViewCellMd.audioType==0){
            // 我的 xsNumberRobot_digitalHumanVoiceId
            pramerDict = @{
                @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
                @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
                @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
                
                //1080.0 1920.0
    //            @"width":@(self.xsNumberRobot_width),//视频宽度
    //            @"height":@(self.xsNumberRobot_height),//视频高度
                @"width":@(1080.0),//视频宽度
                @"height":@(1920.0),//视频高度
                @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
    //            @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
                @"title":self.xsNumberRobot_title,//标题
                @"text":self.xsNumberRobot_text,//视频（字幕）内容
                @"musicId":self.xsNumberRobot_musicId,//背景音乐id
                @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
                @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
                @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
                @"materials":self.xsNumberRobot_materials,//素材列表
                
                @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
//                @"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
                @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
               
                
                @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
                @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
        //
                @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
                @"titleStyle":self.xsNumberRobot_titleStyle,
                
                @"materialStyle":self.xsNumberRobot_materialStyle,
                @"assStyle":self.xsNumberRobot_assStyle,//
        //
                
                
            };
        }
        else{
            // 官方 xsNumberRobot_voiceTemplateId
            pramerDict = @{
                @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
                @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
                @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
                
                //1080.0 1920.0
    //            @"width":@(self.xsNumberRobot_width),//视频宽度
    //            @"height":@(self.xsNumberRobot_height),//视频高度
                @"width":@(1080.0),//视频宽度
                @"height":@(1920.0),//视频高度
                @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
    //            @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
                @"title":self.xsNumberRobot_title,//标题
                @"text":self.xsNumberRobot_text,//视频（字幕）内容
                @"musicId":self.xsNumberRobot_musicId,//背景音乐id
                @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
                @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
                @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
                @"materials":self.xsNumberRobot_materials,//素材列表
                
                @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
                @"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
//                @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
               
                
                @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
                @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
        //
                @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
                @"titleStyle":self.xsNumberRobot_titleStyle,
                
                @"materialStyle":self.xsNumberRobot_materialStyle,
                @"assStyle":self.xsNumberRobot_assStyle,//
        //
                
                
            };
        }
        
    }
    
    NSLog(@"xsPreviewNumberRobotData--pramerDict==%@\n",pramerDict);
    
    
    
    
    [MBProgressHUD showMessage:kLocalizedString(@"...")];
    

    
    [YSHelp wqWriteData:[NSString stringWithFormat:@"tempUrl==%@    pramerDict==%@ res==%@",tempUrl,pramerDict,pramerDict] withFileName:@"xsPreviewNumberRobotDataWithBuildType--111"];
    
    //- (void)xsUniappPreviewOrExportWithDictnary:(NSDictionary *)dictData withType:(NSInteger)buildTypeInt
    [self xsUniappPreviewOrExportWithDictnary:pramerDict withType:buildTypeInt];
    
    // digitalHumanStyle false  DigitalHumanGraphicalObjectDTO这个参数其实是dictionary
//    [[ZYFDataManager sharedInstance] POST:tempUrl dict:pramerDict succeed:^(id data) {
//
//
//        NSDictionary *tempDict = data;
//
//        [YSHelp wqWriteData:[NSString stringWithFormat:@"tempUrl==%@    pramerDict==%@ res==%@",tempUrl,pramerDict,tempDict] withFileName:@"xsPreviewNumberRobotDataWithBuildType--111"];
//
//        NSLog(@"xsPreviewNumberRobotData-pramerDict===%@\n",pramerDict);
//        NSLog(@"xsPreviewNumberRobotData-tempUrl===%@\n",tempUrl);
//        NSLog(@"xsPreviewNumberRobotData-tempDict===%@\n",tempDict);
//        //buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//
//        int codeInt = [tempDict[@"code"] intValue];
//
//
//        if(codeInt==200){
//            NSString *dataStr;// = [tempDict[@"data"] intValue];
//            if([tempDict[@"data"] isKindOfClass:[NSString class]]){
//                dataStr = tempDict[@"data"];
//            }
//            else if([tempDict[@"data"] isKindOfClass:[NSNumber class]]){
//                dataStr = [NSString stringWithFormat:@"%d",[tempDict[@"data"] intValue]];
//            }
//
//            [weakSelf xsSearchPreviewNumberRobotVideoDataWithBuildType:buildTypeInt withDataString:dataStr];
//        }
//        else{
//            NSString *message = tempDict[@"message"];
//            if([NSString zyf_isEmpty:message]){
//                message = tempDict[@"msg"];
//            }
//            if(kStringIsEmpty(message)){
//
//                //buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//                if(buildTypeInt==1){
//                    message = kLocalizedString(@"预览失败，请稍后重试！");
//                }
//                else if(buildTypeInt==2){
//                    message = kLocalizedString(@"导出失败，请稍后重试！");
//                }
//                else if(buildTypeInt==3){
//                    message = kLocalizedString(@"快速创作失败，请稍后重试！");
//                }
//                else{
//                    message = kLocalizedString(@"数据请求失败，请稍后重试！");
//                }
//
//            }
//            [MBProgressHUD showError:message];
//        }
//
//
//    } failure:^(NSDictionary *error) {
//        NSLog(@"xsPreviewNumberRobotData---error.description==%@\n",error.description);
//
//        [MBProgressHUD showError:error.description];
//
//        [YSHelp wqWriteData:[NSString stringWithFormat:@"tempUrl==%@    pramerDict==%@ error.description==%@",tempUrl,pramerDict,error.description] withFileName:@"xsPreviewNumberRobotDataWithBuildType--error.description"];
//    }];
}
//{
//    //self.xsConfigurationMusicCollectionViewCellMd;
//    
//    XSWeakSelf;
//
//    NSString *tempUrl = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"digitalHuman/createTask"];
//
//    
////    self.xsNumberRobot_buildType = @"1";
////    self.xsNumberRobot_aspectRatio = @"1";
////    self.xsNumberRobot_smartHighlightingEnabled = @"0";
////    self.xsNumberRobot_width = 200.0;
////    self.xsNumberRobot_height = 270.0;
//    
//    //背景图片地址 背景颜色
//    if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)&&kStringIsEmpty(self.xsNumberRobot_backgroundColor)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择背景图片或背景颜色")];
//        return;
//    }
//    
////if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)){
////
////    [MBProgressHUD showError:kLocalizedString(@"请先选择背景图片")];
////    return;
////
//////        xsNumberRobot_digitalHumanStyle
////}
//    //背景图片地址
////    weakSelf.xsNumberRobot_backgroundImageUrl = [cbModel.previewImage copy];
//    
//    
//    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕
//    //@property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
//    xsCropBaseImageView *tempFindCropImg;
//    for (xsCropBaseImageView *tempCropImg in self.TestRobotCropCurrentMarray) {
//        if(tempCropImg.cropTag==0){
//            
//            tempFindCropImg = tempCropImg;
//            break;
//        }
//    }
//    
//    
//    // 获取子视图在父视图中的坐标
//    CGPoint digitalHumanStyleIntopImgBgViewLocation = [tempFindCropImg convertPoint:CGPointZero toView:self.topImgBgView];
//    //NSLog(@"子视图在父视图中的位置1： (%f, %f)", childViewPositionInParentView.x, childViewPositionInParentView.y);
//    
//    CGPoint xsbossBackgroundImagePoint = [self.bossBackgroundImage convertPoint:CGPointZero toView:self.topImgBgView];
//   // NSLog(@"子视图在父视图中的位置2： (%f, %f)", xsbossBackgroundImagePoint.x, xsbossBackgroundImagePoint.y);
//    
//    CGFloat digitalHumanStyleX = digitalHumanStyleIntopImgBgViewLocation.x - xsbossBackgroundImagePoint.x;
//    CGFloat digitalHumanStyleY = digitalHumanStyleIntopImgBgViewLocation.y - xsbossBackgroundImagePoint.y;
//    NSLog(@"digitalHumanStyleX-Y： (%f, %f)", digitalHumanStyleX, digitalHumanStyleY);
//
//    NSLog(@"self.bossBackgroundImage在topImgBgView中的位置: (%f, %f)", self.bossBackgroundImage.origin.x, self.bossBackgroundImage.origin.y);
//    
////    CGPoint childViewPositionInParentView2 = [tempFindCropImg convertPoint:CGPointZero toView:self.bossBackgroundImage];
////    NSLog(@"子视图在父视图中的位置5： (%f, %f)", childViewPositionInParentView2.x, childViewPositionInParentView2.y);
//    
////    CGFloat tempFindCropImgX = childViewPositionInParentView.x;
////    CGFloat tempFindCropImgY = ;
//    self.xsNumberRobot_digitalHumanStyle =
//    @{@"path":[self.xsNumberRobot_backgroundImageUrl copy],
//      @"order":@(1),
//      @"x":@(digitalHumanStyleX),
//      @"y":@(digitalHumanStyleY),
//      @"width":@(tempFindCropImg.width),
//      @"height":@(tempFindCropImg.height)};
//    
//    //NSString *xsdigitalHumanStyleStr = [NSString convertToJsonData:Mdddict];
//    
//    
//    //标题
//    if(kStringIsEmpty(self.xsNumberRobot_title)){
//        [MBProgressHUD showError:kLocalizedString(@"请先填写标题")];
//        return;
//    }
//    
//    self.xsNumberRobot_text = [self.RobotBottomView xsGetInputCopywritingText];
//    //视频（字幕）内容
//    if(kStringIsEmpty(self.xsNumberRobot_text)){
//        [MBProgressHUD showError:kLocalizedString(@"请先填写视频（字幕）内容")];
//        return;
//    }
//    
//    
//    //背景音乐id
//    if(kStringIsEmpty(self.xsNumberRobot_musicId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择背景音乐")];
//        return;
//    }
//    
//    
//    //数字人id
//    if(kStringIsEmpty(self.xsNumberRobot_digitalHumanId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择数字人")];
//        return;
//    }
//
//    //语音模板id
//    if(kStringIsEmpty(self.xsNumberRobot_voiceTemplateId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择语音模板")];
//        return;
//    }
//    
//    //数字人声音id
//    if(kStringIsEmpty(self.xsNumberRobot_digitalHumanVoiceId)){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择数字人声音")];
//        return;
//    }
//    
//    
//    //素材列表
//    if(self.xsSelectAddMaterialModelMarray.count<=0){
//        [MBProgressHUD showError:kLocalizedString(@"请先选择素材")];
//        return;
//    }
////    //素材列表
////    if(self.xsNumberRobot_materials.count<=0){
////        [MBProgressHUD showError:kLocalizedString(@"请先选择素材")];
////        return;
////    }
//    
////    type    素材类型 1.图片 2.视频        false integer(int32)
////    path    文件地址     false string
//    NSMutableArray *tempMaterialsMarr = [[NSMutableArray alloc] initWithCapacity:self.xsSelectAddMaterialModelMarray.count];
//    
//        for (xsSelectAddMaterialCollectionViewCellModel *findSelectItemModel in self.xsSelectAddMaterialModelMarray) {
//            NSString *xsMaterialFileUrl = findSelectItemModel.url;
//            if(kStringIsEmpty(xsMaterialFileUrl)){
//                xsMaterialFileUrl = [NSString new];
//            }
//            NSString *xsMaterialType=@"1";
//            if([xsMaterialFileUrl containsString:@".mp4"]){
//                xsMaterialType = @"2";
//            }
//            NSDictionary *tempMaterialDict = @{@"type":xsMaterialType,@"path":xsMaterialFileUrl};
//            [tempMaterialsMarr addObject:tempMaterialDict];
//        }
//    
//    self.xsNumberRobot_materials = [NSArray arrayWithArray:tempMaterialsMarr];
//    
//    
//    
//    
//    //xsNumberRobot_textObjects
//    // 获取普通文本列表
//    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕 4及以上为普通文本
//    //@property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
//    NSMutableArray *textObjectsMarray = [[NSMutableArray alloc] init];
//    for (xsCropBaseLabel *tempCropLabel3 in self.TestRobotCropCurrentMarray) {
//        if(tempCropLabel3.cropTag>=3){
//            
//            
//            // 获取子视图在父视图中的坐标
//            CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
//            
//            CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
//            CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
//            
//            NSLog(@"文本的位置tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f",tempCropLabel3X,tempCropLabel3Y);
//            //type    文本类型 0普通文本 1字幕 2标题
//            NSString *contentStr = [NSString stringWithFormat:@"%@",tempCropLabel3.recodeBaseStr];
//            NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
//            NSString *typeStr = @"0";
//            if(tempCropLabel3.cropTag==3){
//                typeStr = @"1";
//            }
//            //x轴位置 单位px 视频左上角为原点
//            NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X];
//            //y轴位置 单位px 视频左上角为原点
//            NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y];
//            NSString *fontSizeStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3.xsTextSizeF];
//            NSString *fontNameStr;// = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
//            if(!kStringIsEmpty(tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer)){
//                fontNameStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
//            }
//            else{
//                fontNameStr = [NSString new];
//            }
//            NSString *primaryColourStr;
//            if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.primaryColour)){
//                primaryColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.primaryColour];
//            }
//            else{
//                primaryColourStr = [NSString new];
//            }
//            NSString *outlineColourStr;
//            if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
//                outlineColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.outlineColour];
//            }
//            else{
//                outlineColourStr = [NSString new];
//            }
//            NSString *outlineStr = [NSString stringWithFormat:@"%@",@"0"];
//            if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
//                outlineStr = @"1";
//            }
//            
//           NSDictionary *tempTextDict = @{@"content":contentStr,
//                                          @"order":@([orderStr integerValue]),
//                                          @"type":@([typeStr intValue]),
//                                          @"marginL":@([marginLStr doubleValue]),
//                                          @"marginV":@([marginVStr doubleValue]),
//                                          @"fontSize":@([fontSizeStr intValue]),
//                                          @"fontName":fontNameStr,
//                                          @"primaryColour":primaryColourStr,
//                                          @"outlineColour":outlineColourStr,
//                                          @"outline":@([outlineStr intValue])};
//            
//            [textObjectsMarray addObject:tempTextDict];
//        }
//        else{
//            
//            if(tempCropLabel3.cropTag==2){// 标题
//                
//                // 获取子视图在父视图中的坐标
//                CGPoint tempCropLabel3Point = [tempCropLabel3 convertPoint:CGPointZero toView:self.topImgBgView];
//                
//                CGFloat tempCropLabel3X = tempCropLabel3Point.x - xsbossBackgroundImagePoint.x;
//                CGFloat tempCropLabel3Y =  tempCropLabel3Point.y - xsbossBackgroundImagePoint.y;
//                
//                NSLog(@"文本的位置tempCropLabel3X==%.2f  tempCropLabel3Y==%.2f",tempCropLabel3X,tempCropLabel3Y);
//                //type    文本类型 0普通文本 1字幕 2标题
//                NSString *contentStr = [NSString stringWithFormat:@"%@",tempCropLabel3.recodeBaseStr];
//                NSString *orderStr = [NSString stringWithFormat:@"%ld",tempCropLabel3.cropTag];
//                NSString *typeStr = @"0";
//                if(tempCropLabel3.cropTag==3){
//                    typeStr = @"1";
//                }
//                //x轴位置 单位px 视频左上角为原点
//                NSString *marginLStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3X];
//                //y轴位置 单位px 视频左上角为原点
//                NSString *marginVStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3Y];
//                NSString *fontSizeStr = [NSString stringWithFormat:@"%.2f",tempCropLabel3.xsTextSizeF];
//                NSString *fontNameStr;// = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
//                if(!kStringIsEmpty(tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer)){
//                    fontNameStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontFamilyMd.fontNameLinuxServer];
//                }
//                else{
//                    fontNameStr = [NSString new];
//                }
//                NSString *primaryColourStr;
//                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.primaryColour)){
//                    primaryColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.primaryColour];
//                }
//                else{
//                    primaryColourStr = [NSString new];
//                }
//                NSString *outlineColourStr;
//                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
//                    outlineColourStr = [NSString stringWithFormat:@"%@",tempCropLabel3.xsFontStyleMd.outlineColour];
//                }
//                else{
//                    outlineColourStr = [NSString new];
//                }
//                NSString *outlineStr = [NSString stringWithFormat:@"%@",@"0"];
//                if(!kStringIsEmpty(tempCropLabel3.xsFontStyleMd.outlineColour)){
//                    outlineStr = @"1";
//                }
//                
//               NSDictionary *tempTextDict = @{@"content":contentStr,
//                                              @"order":@([orderStr integerValue]),
//                                              @"type":@([typeStr intValue]),
//                                              @"marginL":@([marginLStr doubleValue]),
//                                              @"marginV":@([marginVStr doubleValue]),
//                                              @"fontSize":@([fontSizeStr intValue]),
//                                              @"fontName":fontNameStr,
//                                              @"primaryColour":primaryColourStr,
//                                              @"outlineColour":outlineColourStr,
//                                              @"outline":@([outlineStr intValue])};
//                
//                self.xsNumberRobot_titleStyle = tempTextDict;
//            }
//        }
//    }
//    self.xsNumberRobot_textObjects = [NSArray arrayWithArray:textObjectsMarray];
//    
//    NSDictionary *pramerDict;
//    
//    if(kStringIsEmpty(self.xsNumberRobot_backgroundImageUrl)){
//        pramerDict = @{
//            @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//            @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
//            @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
//            
//            @"width":@(self.xsNumberRobot_width),//视频宽度
//            @"height":@(self.xsNumberRobot_height),//视频高度
////            @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
//            @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
//            @"title":self.xsNumberRobot_title,//标题
//            @"text":self.xsNumberRobot_text,//视频（字幕）内容
//            @"musicId":self.xsNumberRobot_musicId,//背景音乐id
//            @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
//            @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
//            @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
//            @"materials":self.xsNumberRobot_materials,//素材列表
//            
//            @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
//            @"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
//            @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
//           
//            
//    //        @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
//            @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
//    //
//            @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
//            @"titleStyle":self.xsNumberRobot_titleStyle
//    //        @"materialStyle":self.xsNumberRobot_materialStyle,
//    //        @"assStyle":self.xsNumberRobot_assStyle,//
//    //
//            
//            
//            
//        };
//    }
//    else{
//        pramerDict = @{
//            @"buildType":self.xsNumberRobot_buildType,//生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//            @"aspectRatio":self.xsNumberRobot_aspectRatio,//视频比例 1竖屏 2横屏
//            @"smartHighlightingEnabled":self.xsNumberRobot_smartHighlightingEnabled,// 是否开启智能划重点 0 关闭 1 开启
//            
//            @"width":@(self.xsNumberRobot_width),//视频宽度
//            @"height":@(self.xsNumberRobot_height),//视频高度
//            @"backgroundImageUrl":self.xsNumberRobot_backgroundImageUrl,//背景图片地址
////            @"backgroundColor":self.xsNumberRobot_backgroundColor,//背景颜色 (纯色背景) 和背景图片只能选一个传 16进制格式 #000000
//            @"title":self.xsNumberRobot_title,//标题
//            @"text":self.xsNumberRobot_text,//视频（字幕）内容
//            @"musicId":self.xsNumberRobot_musicId,//背景音乐id
//            @"musicVolume":self.xsNumberRobot_musicVolume,//背景音乐音量
//            @"speechRate":self.xsNumberRobot_speechRate,//声音的语速。 值越高，语速越快；值越低，语速越慢。 范围0.5-2.0,示例值(1.25)
//            @"volume":self.xsNumberRobot_volume,//声音的音量。 值越高，音量越大；值越低，音量越小。取值范围：0-100,示例值(75)
//            @"materials":self.xsNumberRobot_materials,//素材列表
//            
//            @"digitalHumanId":self.xsNumberRobot_digitalHumanId,//数字人id
//            @"voiceTemplateId":self.xsNumberRobot_voiceTemplateId,//语音模板id
//            @"digitalHumanVoiceId":self.xsNumberRobot_digitalHumanVoiceId,//数字人声音id
//           
//            
//    //        @"graphicalObjects":self.xsNumberRobot_graphicalObjects,//普通图形对象列表
//            @"textObjects":self.xsNumberRobot_textObjects,//普通文本对象列表
//    //
//            @"digitalHumanStyle":self.xsNumberRobot_digitalHumanStyle,//
//            @"titleStyle":self.xsNumberRobot_titleStyle
//            
//    //        @"materialStyle":self.xsNumberRobot_materialStyle,
//    //        @"assStyle":self.xsNumberRobot_assStyle,//
//    //
//            
//            
//        };
//    }
//    
//    NSLog(@"xsPreviewNumberRobotData--pramerDict==%@\n",pramerDict);
//    
//    
//    [MBProgressHUD showMessage:kLocalizedString(@"...")];
//    // digitalHumanStyle false  DigitalHumanGraphicalObjectDTO这个参数其实是dictionary
//    [[ZYFDataManager sharedInstance] POST:tempUrl dict:pramerDict succeed:^(id data) {
//        
//        
//        NSDictionary *tempDict = data;
//        
//        NSLog(@"xsPreviewNumberRobotData-pramerDict===%@\n",pramerDict);
//        NSLog(@"xsPreviewNumberRobotData-tempUrl===%@\n",tempUrl);
//        NSLog(@"xsPreviewNumberRobotData-tempDict===%@\n",tempDict);
//        //buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//        
//        int codeInt = [tempDict[@"code"] intValue];
//        
//        
//        if(codeInt==200){
//            NSString *dataStr;// = [tempDict[@"data"] intValue];
//            if([tempDict[@"data"] isKindOfClass:[NSString class]]){
//                dataStr = tempDict[@"data"];
//            }
//            else if([tempDict[@"data"] isKindOfClass:[NSNumber class]]){
//                dataStr = [NSString stringWithFormat:@"%d",[tempDict[@"data"] intValue]];
//            }
//            
//            [weakSelf xsSearchPreviewNumberRobotVideoDataWithBuildType:buildTypeInt withDataString:dataStr];
//        }
//        else{
//            NSString *message = tempDict[@"message"];
//            if([NSString zyf_isEmpty:message]){
//                message = tempDict[@"msg"];
//            }
//            if(kStringIsEmpty(message)){
//                
//                //buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
//                if(buildTypeInt==1){
//                    message = kLocalizedString(@"预览失败，请稍后重试！");
//                }
//                else if(buildTypeInt==2){
//                    message = kLocalizedString(@"导出失败，请稍后重试！");
//                }
//                else if(buildTypeInt==3){
//                    message = kLocalizedString(@"快速创作失败，请稍后重试！");
//                }
//                else{
//                    message = kLocalizedString(@"数据请求失败，请稍后重试！");
//                }
//                
//            }
//            [MBProgressHUD showError:message];
//        }
//        
//        
//    } failure:^(NSDictionary *error) {
//        NSLog(@"xsPreviewNumberRobotData---error.description==%@\n",error.description);
//        
//        [MBProgressHUD showError:error.description];
//    }];
//}


#pragma mark 查询数字人视频任务
// buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
- (void)xsSearchPreviewNumberRobotVideoDataWithBuildType:(NSInteger)buildTypeInt withDataString:(NSString *)dString
{
    
    XSWeakSelf;

    NSString *tempUrl = [NSString stringWithFormat:@"%@%@?taskId=%@",API_BASEURL_BossIP,@"digitalHuman/getTask",dString];

   
    NSDictionary *pramerDict;// = @{@"taskId":dString};
    
    if(!kStringIsEmpty(dString)){
        pramerDict = @{@"taskId":dString};
        
    }
    else{
        pramerDict = @{@"taskId":[NSString new]};
    }
    
    
    NSLog(@"getTask--pramerDict==%@\n",pramerDict);
    
    
    NSString *message;
    if(buildTypeInt==1){
        message = kLocalizedString(@"预览数据获取中...");
    }
    else if(buildTypeInt==2){
        message = kLocalizedString(@"导出数据获取中...");
    }
    else if(buildTypeInt==3){
        message = kLocalizedString(@"快速创作数据获取中...");
    }
    else{
        message = kLocalizedString(@"数据获取中...");
    }
    [MBProgressHUD showMessage:message];
    
    [[ZYFDataManager sharedInstance] POST:tempUrl dict:pramerDict succeed:^(id data) {
        
        
        NSDictionary *tempDict = data;
        
        NSLog(@"getTask-pramerDict===%@\n",pramerDict);
        NSLog(@"getTask-tempUrl===%@\n",tempUrl);
        
        NSLog(@"getTask-tempDict===%@\n",tempDict);
//        getTask-tempDict==={
//            code = 200;
//            data =     {
//                coverUrl = "https://payment-writemall-com.oss-cn-shenzhen.aliyuncs.com/sv/firstFrame/695b3aa0-3d83-404a-9a6f-a6311b413e4e.jpg";
//                createTime = "2024-09-20 11:22:35";
//                duration = "<null>";
//                finishTime = "<null>";
//                progress = 0;
//                startTime = "<null>";
//                status = 0;
//                taskId = "<null>";
//                title = "\U6807\U9898\U6807\U9898";
//                videoUrl = "<null>";
//            };
//            message = "\U6210\U529f";
//        }
        if(tempDict){
            if([tempDict isKindOfClass:[NSDictionary class]]){
                int codeInt = [tempDict[@"code"] intValue];
                if(codeInt==200){

                    if([tempDict[@"data"] isKindOfClass:[NSDictionary class]]){
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf xsUniappPreviewOrExportWithDictnary:tempDict[@"data"] withType:buildTypeInt];
                        });
                    }
                    else{
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [MBProgressHUD showError:kLocalizedString(@"数据获取有误")];
                        });
                    }
                }
                else{
                    NSString *message = tempDict[@"message"];
                    if(notNillStr(message)){
                    }else{
                        message = tempDict[@"msg"];
                        if(!notNillStr(message)){

                            if(buildTypeInt==1){
                                message = kLocalizedString(@"预览数据任务获取有误");
                            }
                            else if(buildTypeInt==2){
                                message = kLocalizedString(@"导出数据任务获取有误");
                            }
                            else if(buildTypeInt==3){
                                message = kLocalizedString(@"快速创作任务数据获取有误");
                            }
                            else{
                                message = kLocalizedString(@"数据获取有误");
                            }
                        }
                    }
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [MBProgressHUD showError:message];
                    });
                }
            }
            else{
                dispatch_async(dispatch_get_main_queue(), ^{
                    [MBProgressHUD showError:kLocalizedString(@"数据获取有误")];
                });
            }
        }
        else{
            dispatch_async(dispatch_get_main_queue(), ^{
                [MBProgressHUD showError:kLocalizedString(@"数据获取有误")];
            });
        }
        
    } failure:^(NSDictionary *error) {
        NSLog(@"getTask---error.description==%@\n",error.description);
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD showError:kLocalizedString(@"数据获取有误")];
        });
    }];
}
#pragma mark uniapp进行预览导出
// buildType 生成类型 1预览（自由创作） 2导出（自由创作） 3快速创作
- (void)xsUniappPreviewOrExportWithDictnary:(NSDictionary *)dictData withType:(NSInteger)buildTypeInt{
    
    NSString *buildTypeStr = [NSString stringWithFormat:@"%ld",buildTypeInt];
    // typeStatu 2 图片 3视频
    //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
    // action 2004 跳转到视频字幕
    // action 2005 预览 导出
//[self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2005",@"data":dictData,@"buildType":buildTypeStr}} domChanges:nil];
}

#pragma mark 点击底部文字时是否创建CropLabel
- (void)xsShowTextViewWithIsCreateCropLabel{
    
    
    //    //TestRobotCropViewMarray记录的是拖动的四个角和四条边  cropTag 0 素材 1数字人 2标题 3字幕
    //    @property (nonatomic,strong)NSMutableArray *TestRobotCropViewMarray;
    //    //TestRobotCropCurrentMarray记录的是四个角和四条边框住的view(imgview label)cropTag 0 数字人 1素材 2标题 3字幕
    //    @property (nonatomic,strong)NSMutableArray *TestRobotCropCurrentMarray;
    //    // 记录点击页面上的控件 可能是 xsCropBaseLabel xsCropBaseImageView这两个
    //    @property (nonatomic,weak) UIView *recordUserDragView;//
        
        if([self.recordUserDragView isKindOfClass:[xsCropBaseImageView class]]){
            // 说明上传点击的不是croplabel 要重新创建
            
            ++self.xsCreateCropViewCout;
            CGFloat robitItemViewY = (self.topImgBgView.height-self.xsNumberRobot_height)*0.5;
            CGFloat cropLabelY = robitItemViewY+30;
            [self xsTestRobotCropImageViewWithCropTag:self.xsCreateCropViewCout withImgOrLabel:CropView_label withImageSource:nil withTitle:@"输入文本" withOffsetY:cropLabelY+50];
            
            [self wqWriteData:[NSString stringWithFormat:@"%ld",self.xsCreateCropViewCout] withFileName:@"go-22"];
            
            //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
            [self xsHidenNotCurentRectViewWithCropTage:self.xsCreateCropViewCout withIsHiddenAllImageAndLabel:NO];
            
            //查找当前被选中的label或者imageview
            [self xsFindUserDragViewWithCropTage:self.xsCreateCropViewCout];
            
            if(_xsTextView){
                [_xsTextView xsTopInputTextFeildTextString:@""];
            }
            
            if([self.recordUserDragView isKindOfClass:[xsCropBaseLabel class]]){
                xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
                
                //设置xsTextView中的输入文字及placehold文字提示
                [self bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:tempLabel.cropTag];
            }
            
            
            for (xsCropBaseView *cropViewFrameItem in self.TestRobotCropCurrentMarray) {
                if(cropViewFrameItem.cropTag==self.xsCreateCropViewCout){
                    
                    [self xsChangeTopLeftDeleteButtonViewFrameWith:cropViewFrameItem];
                    break;
                }
            }
        }
        else{
            //说明是上次是选中了croplabel
            xsCropBaseLabel *tempLabel = (xsCropBaseLabel *)self.recordUserDragView;
            NSString *tempString = tempLabel.recodeBaseStr;
            if(_xsTextView){
                if(!kStringIsEmpty(tempString)){
                    [_xsTextView xsTopInputTextFeildTextString:tempString];
                }
            }
            [self wqWriteData:[NSString stringWithFormat:@"%ld",tempLabel.cropTag] withFileName:@"go-33"];
            
            NSLog(@"tempLabel.cropTag--tempLabel.cropTag--tempLabel.cropTag22==%ld\n",tempLabel.cropTag);
            //    *TestRobotCropViewMarray;// 0数字人  1素材 2标题 3字幕
            //    *TestRobotCropCurrentMarray;//  0数字人  1素材 2标题 3字幕
            if(tempLabel.cropTag==2){
                if(_RobotBottomView){
                    [_RobotBottomView xsChangeTitleButtonIsClick:YES];
                    
                    [self xsTitleIsHiden:NO];
                    
                    //cropTag  0 数字人 1素材 2标题 3字幕
                    [self xsHidenNotCurentRectViewWithCropTage:2 withIsHiddenAllImageAndLabel:NO];
                    [self xsFindUserDragViewWithCropTage:2];
                    
                    //设置xsTextView中的输入文字及placehold文字提示
                    [self bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:2];
                }
            }
            else if(tempLabel.cropTag==3){
                if(_RobotBottomView){
                    [_RobotBottomView xsChangeSubtitlesButtonIsClick:YES];
                    
                    
                    [self xsSubtitlesIsHiden:NO];
                    
                    //cropTag  0 数字人 1素材 2标题 3字幕
                    [self xsHidenNotCurentRectViewWithCropTage:3 withIsHiddenAllImageAndLabel:NO];
                    [self xsFindUserDragViewWithCropTage:3];
                    
                    //设置xsTextView中的输入文字及placehold文字提示
                    [self bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:3];
                }
            }
            else{
                NSLog(@"tempLabel.cropTag--tempLabel.cropTag--tempLabel.cropTag==%ld\n",tempLabel.cropTag);
                
           
                
                [self xsFindUserDragViewWithCropTage:tempLabel.cropTag];
                
                
                //隐藏不是选中的view的delete按钮
                [self xsHidenNotCurrenDeleteButtonWithCropTag:tempLabel.cropTag];
                
                //隐藏不是当前选中拖动view的四个角和四条边的view(label和imgview)
                [self xsHidenNotCurentRectViewWithCropTage:tempLabel.cropTag withIsHiddenAllImageAndLabel:NO];
                
                
                //设置xsTextView中的输入文字及placehold文字提示
                [self bossChangeXsTextViewTextAndxsTextViewIsShowHiddenWith:tempLabel.cropTag];
            }
        }
    }

//CGFloat xsCropBtnW = 25;
//CGFloat xsCropBtnH = 30;
//CGFloat xsCropBtnX = CGRectGetMinX(xsTestRobotImageView.frame)-xsCropBtnW;
//CGFloat xsCropBtnY = CGRectGetMinY(xsTestRobotImageView.frame);
//xsCropBaseButton *xsCropBtn = [self xsGetTopLeftDeleteButtonWithCropTag:cTag];
//[self.topImgBgView addSubview:xsCropBtn];
//[self.TestRobotCropViewTopLeftDeleteButtonsMarray addObject:xsCropBtn];
//xsCropBtn.frame = CGRectMake(xsCropBtnX, xsCropBtnY, xsCropBtnW, xsCropBtnH);
//
//[self xsHidenNotCurrenDeleteButtonWithCropTag:cTag];
#pragma mark 隐藏不是选中的view的delete按钮
- (void)xsHidenNotCurrenDeleteButtonWithCropTag:(NSInteger)cropTg{
    
    
    //NSLog(@"xsHidenNotCurrenDeleteButtonWithCropTag-==%ld",cropTg);
    

        //xsCropBaseView *tempFindItemView;
        for (xsCropBaseView *tempItemView in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
            if(tempItemView.cropTag!=cropTg){
                tempItemView.hidden = YES;
            }
            else{
                
                if(tempItemView.cropTag>3){
                    tempItemView.hidden = NO;
                }
                else{
                    tempItemView.hidden = YES;
                }
            }
        }
   
 
    
    
//    // 查找选中的label并给输入框设置值
//    if(_xsTextView){
//        BOOL isFindLabel = NO;
//        for(xsCropBaseLabel *tempCropItemLabel in self.TestRobotCropCurrentMarray){
//            if([tempCropItemLabel isKindOfClass:[xsCropBaseLabel class]]){
//                if(tempCropItemLabel.cropTag==cropTg){
//                    [_xsTextView xsChangeTextString:[tempCropItemLabel.recodeBaseStr copy]];
//                    isFindLabel = YES;
//                    break;
//                }
//            }
//        }
//        //    *TestRobotCropViewMarray;// 0数字人  1素材 2标题 3字幕
//        //    *TestRobotCropCurrentMarray;//  0数字人  1素材 2标题 3字幕
//        if(!isFindLabel){
//            [_xsTextView xsChangeTextString:@""];
//            [self hide_xsTextView];
//        }
//        else{
//            [self show_xsTextView];
//        }
//        
//        
//        
//        if(cropTg>0){
//            if(cropTg==3){
//                [_xsTextView bossChangeTopInputTextFeildPlaceholderWithbossTopTextPlaceholdType:TopTextPlaceholdType_Subtitles];
//            }
//            else{
//                [_xsTextView bossChangeTopInputTextFeildPlaceholderWithbossTopTextPlaceholdType:TopTextPlaceholdType_text];
//            }
//        }
//    }
    
    
}

#pragma mark 隐藏全部左上角删除按钮
- (void)xsHiddenAllTopLeftDeleteButton{
    
    for (xsCropBaseView *tempItemView in self.TestRobotCropViewTopLeftDeleteButtonsMarray) {
        tempItemView.hidden = YES;
    }
}
//cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
// BttomView.tag  0老板IP  1配音  2背景  3文字  4音乐 5素材 6选中的素材列表
#pragma mark 根据cropTg显示底部
- (void)xsShowBottomEditorStatuWithCropTg:(NSInteger)cropT{
    
    
    
    // 0 数字人 1素材  2 标题 3字幕  ...N 以上都是普通文本
    if(cropT==0){
        //[self.EditeDigitalRobotTitleV showViewWithType:xsEditeDigitalRobot_digitalRobotImg];
        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_digitalRobotImg];
    }
    else if(cropT==1){
//            [self.EditeDigitalRobotTitleV showViewWithType:xsEditeDigitalRobot_backgroundImg];
        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_backgroundImg];
    }
//    else if(cropT==2){
////            [self.EditeDigitalRobotTitleV showViewWithType:xsEditeDigitalRobot_bigTitle];
//        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_bigTitle];
//    }
//    else if(cropT==3){
////            [self.EditeDigitalRobotTitleV showViewWithType:xsEditeDigitalRobot_smallTitle];
//        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_smallTitle];
//    }
    else{
//            [self.EditeDigitalRobotTitleV showViewWithType:xsEditeDigitalRobot_smallTitle];
//        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_smallTitle];
        [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_bigTitle];
    }
    
    
}

//cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
// BttomView.tag  0老板IP  1配音  2背景  3文字  4音乐 5素材 6选中的素材列表
#pragma mark 根据cropTg显示底部面板
- (void)xsShowBootmPanelWithCropTg:(NSInteger)cropT{
    
//    //显示点击老板IP 对应的视图
//    - (void)show_xsDigitalRobotBossIPViewBgView{
//    - (void)hide_xsDigitalRobotBossIPViewBgView{
//
//    #pragma mark 配音 对应的视图
//    - (void)show_xsCongfgonfigurationMusicView{
//    - (void)hide_xsCongfgonfigurationMusicView{
//
//    #pragma mark 选择背景 对应的视图
//    - (void)show_xsBackgroundView{
//    - (void)hide_xsBackgroundView{
//
//
//    #pragma mark 文字 对应的视图
//    - (void)show_xsTextView{
//    - (void)hide_xsTextView{
//
//
//    #pragma mark 选择背景音乐 对应的视图
//    - (void)show_BossIPBackgroundView{
//    - (void)hide_BossIPBackgroundView{


    BOOL isHaveView = NO;
    //NSInteger BttomViewTag = 0;
    //默认self.xsRecrodBottomShowPanViewMarray视图 只有显示过一遍才有
    //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
    if(cropT==0){
        for (xsBossIpBottomBaseView *BttomView in self.xsRecrodBottomShowPanViewMarray) {
            if(BttomView.tag==0){
                // BttomView.tag  0老板IP  1配音  2背景  3文字  4音乐 5素材 6选中的素材列表
                isHaveView = YES;
                //BttomViewTag = 0;
                break;
            }
        }
    }
    else if(cropT==1){
        for (xsBossIpBottomBaseView *BttomView in self.xsRecrodBottomShowPanViewMarray) {
            if(BttomView.tag==6){
                // BttomView.tag  0老板IP  1配音  2背景  3文字  4音乐 5素材
                isHaveView = YES;
               // BttomViewTag = 5;
                break;
            }
        }
    }
    else{
        for (xsBossIpBottomBaseView *BttomView in self.xsRecrodBottomShowPanViewMarray) {
            if(BttomView.tag==3){
                // BttomView.tag  0老板IP  1配音  2背景  3文字  4音乐 5素材
                isHaveView = YES;
                //BttomView.tag=3;
                break;
            }
        }
    }


    if(!isHaveView){
        //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
        if(cropT==0){
            [self show_xsDigitalRobotBossIPViewBgView];
//            [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_digitalRobotImg];
        }
        else if(cropT==1){
            //隐藏素材
//            [self hide_SelectAddMaterialV];
            [self hide_HadAddMaterialListV];
        }
        else if(cropT>=2){// 2标题 3字幕 4及以上普通文本
            [self show_xsTextView];
        }
        return;
    }
    //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
    if(cropT==0){
        // tag  0老板IP  1配音  2背景  3文字  4音乐
        for (xsBossIpBottomBaseView *tempBttomView in self.xsRecrodBottomShowPanViewMarray) {
            if(tempBttomView.tag==0){
                if(!tempBttomView.xsIsShow){
                    [self show_xsDigitalRobotBossIPViewBgView];
                }
//                [self xsShowEdite_Big_Small_Bgimg_DigitalRobotActionWithType:xsEditeDigitalRobot_digitalRobotImg];
            }
            else{
                if(tempBttomView.xsIsShow){
                    if(tempBttomView.tag==1){
                        [self hide_xsCongfgonfigurationMusicView];
                    }
                    else if(tempBttomView.tag==2){
                        [self hide_xsBackgroundView];
                    }
                    else if(tempBttomView.tag==3){
                        [self hide_xsTextView];
                    }
                    else if(tempBttomView.tag==4){
                        [self hide_BossIPBackgroundView];
                    }
                    else if(tempBttomView.tag==6){
                        //隐藏素材
//                        [self hide_SelectAddMaterialV];
                        [self hide_HadAddMaterialListV];
                    }
                }
            }
        }
    }
    else  if(cropT==1){//cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
        // tag  0老板IP  1配音  2背景  3文字  4音乐 5素材
        for (xsBossIpBottomBaseView *tempBttomView in self.xsRecrodBottomShowPanViewMarray) {
            if(tempBttomView.tag==6){// 素材
                if(!tempBttomView.xsIsShow){
                        //显示素材
//                    [self show_SelectAddMaterialV];
                    [self show_HadAddMaterialListV];
                }
            }
            else{
                if(tempBttomView.xsIsShow){
                    if(tempBttomView.tag==0){
                        [self hide_xsDigitalRobotBossIPViewBgView];
                    }
                    else if(tempBttomView.tag==1){
                        [self hide_xsCongfgonfigurationMusicView];
                    }
                    else if(tempBttomView.tag==2){
                        [self hide_xsBackgroundView];
                    }
                    else if(tempBttomView.tag==3){
                        [self hide_xsTextView];
                    }
                    else if(tempBttomView.tag==4){
                        [self hide_BossIPBackgroundView];
                    }
                }
            }
        }
    }
    //cropTag 0 数字人 1素材 2标题 3字幕 4及以上普通文本
    // 这里是文本 包括 标题 字幕 文本
    else{// 这里是cropTag>=2

        for (xsBossIpBottomBaseView *tempBttomView in self.xsRecrodBottomShowPanViewMarray) {
            // tag  0老板IP  1配音  2背景  3文字  4音乐
            if(tempBttomView.tag==3){// tag  0老板IP  1配音  2背景  3文字  4音乐
                if(!tempBttomView.xsIsShow){
                    [self show_xsTextView];
                }
            }
            else{
                if(tempBttomView.xsIsShow){
                    if(tempBttomView.tag==0){
                        [self hide_xsDigitalRobotBossIPViewBgView];
                    }
                    else if(tempBttomView.tag==1){
                        [self hide_xsCongfgonfigurationMusicView];
                    }
                    else if(tempBttomView.tag==2){
                        [self hide_xsBackgroundView];
                    }
                    else if(tempBttomView.tag==4){
                        [self hide_BossIPBackgroundView];
                    }
                    else if(tempBttomView.tag==6){
//                        [self hide_SelectAddMaterialV];
                        [self hide_HadAddMaterialListV];
                    }
                }
            }
        }
    }

//    // 记录底部显示的弹框
//    // tag  0老板IP  1配音  2背景  3文字  4音乐
//    @property (nonatomic,strong)NSMutableArray *xsRecrodBottomShowPanViewMarray;
    
}

#pragma mark -
#pragma mark 弹出选择拍照 从相册获取图片 拍摄视频 star
//#import <MobileCoreServices/MobileCoreServices.h>
//#import <AVFoundation/AVFoundation.h>
//UINavigationControllerDelegate,UIImagePickerControllerDelegat
//typedef NS_ENUM(NSInteger,ImagePickerType) {
//    ImagePickerTypePhotoLibrary,    // 图集
//    ImagePickerTypePhotosAlbum,     // 照片库
//    ImagePickerTypeCameraPhoto,     // 拍照
//    ImagePickerTypeCameraVideo      // 录像
//};
//
////@property (weak, nonatomic) UIImageView *imageView;
//@property (nonatomic, assign) ImagePickerType type;
//@property (nonatomic, strong) UIImagePickerController *imagePicker;
//@property (nonatomic, strong) AVPlayer *player;
- (void)selecterdButtonAction:(UIButton *)sender {
    
//    // typeStatu 2 图片 3视频
//    //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
//    // action 2004 跳转到视频字幕
//    // action 2005 预览 导出
//    // action 2006 弹出上传图片 视频框
//    [self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2006"}} domChanges:nil];

//UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"选择照片" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
//
//// 图集
//UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//
//    self.type = ImagePickerTypePhotoLibrary;
//    [self presentViewController:self.imagePicker animated:YES completion:nil];
//
//}];
//
//// 相片库
//UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"相片库" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//
//    self.type = ImagePickerTypePhotosAlbum;
//    [self presentViewController:self.imagePicker animated:YES completion:nil];
//
//}];
//
//// 相机
//UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//
//    // 判断是否支持相机
//    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//        self.type = ImagePickerTypeCameraPhoto;
//        [self presentViewController:self.imagePicker animated:YES completion:nil];
//    } else {
//        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"未发现相机" preferredStyle:UIAlertControllerStyleAlert];
//        UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//        [alert addAction:action];
//        [self presentViewController:alert animated:YES completion:nil];
//    }
//
//}];
//
//// 录制视频
//UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"录制视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//
//    // 判断是否支持相机
//    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//        self.type = ImagePickerTypeCameraVideo;
//        [self presentViewController:self.imagePicker animated:YES completion:nil];
//    } else {
//        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"未发现相机" preferredStyle:UIAlertControllerStyleAlert];
//        UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//        [alert addAction:action];
//        [self presentViewController:alert animated:YES completion:nil];
//    }
//
//}];
//
//// 取消
//UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
//
//}];
//
//[alertVC addAction:action1];
//[alertVC addAction:action2];
//[alertVC addAction:action3];
//[alertVC addAction:action4];
//[alertVC addAction:action5];
//[self presentViewController:alertVC animated:YES completion:nil];
}
#pragma mark  UIImagePickerControllerDelegate
// 获取图片的回调方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
    
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {

        NSLog(@"video...");
        NSURL *url=[info objectForKey:UIImagePickerControllerMediaURL];//视频路径
        NSString *urlStr=[url path];
        NSLog(@"video--urlStr==%@\n",urlStr);
        
        ////    //    NSString *filePath = @"path/to/your/file.txt";
        ////        NSString *fileName = [filePath lastPathComponent];
        ////        // 移除扩展名
        ////        fileName = [fileName stringByDeletingPathExtension];
        //
//            NSString *tempVideoFileName2 = [urlStr lastPathComponent];
        
//        if(kStringIsEmpty(tempVideoFileName2)){
//
//
//            NSDate *currentDate = [NSDate date];
//            // 创建日期格式化器
//            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//            [dateFormatter setDateFormat:@"yyyyMMddHHmmssSSS"];
//
//            // 格式化当前时间为年月日时分秒毫秒字符串
//            NSString *datetimeString = [dateFormatter stringFromDate:currentDate];
//
//            NSString *timeLocal = [[NSString alloc] initWithFormat:@"%@.MOV", datetimeString];
//            tempVideoFileName2 = timeLocal;
//        }
        
        NSData *tempVideoData3 = [NSData dataWithContentsOfFile:urlStr];
//        [self xsUploadVideoWith:tempVideoFileData2 withName:tempVideoFileName2];
        
        
        NSString *xsVideoPathStr3 = [YSHelp bossIpWriteVideoData:tempVideoData3 withVideoFilePath:urlStr];
        
        if(!kStringIsEmpty(xsVideoPathStr3)){

            NSLog(@"xsPubilicFilePathStr==%@",xsVideoPathStr3);
            
            // typeStatu 2 图片 3视频
            //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
            //action 2004
            //[self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2003",@"xsFilePath":xsVideoPathStr3,@"typeStatu":@"3"}} domChanges:nil];
            
            [YSHelp wqWriteData:[NSString stringWithFormat:@"xsPubilicFilePathStr-6666666---xsVideoPathStr3==%@",xsVideoPathStr3] withFileName:@"xsPubilicFilePathStr-6666666gfgf"];
        }
        else{
            
            [YSHelp wqWriteData:[NSString stringWithFormat:@"tempVideoFileData2-555555---xsVideoPathStr3==%@",xsVideoPathStr3] withFileName:@"tempVideoFileData25-55555swdsf"];
        }
        
        
//        if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(urlStr)) {
//            //保存视频到相簿，注意也可以使用ALAssetsLibrary来保存
//            UISaveVideoAtPathToSavedPhotosAlbum(urlStr, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);//保存视频到相簿
//        }
    } else {
        //_imagePicker.allowsEditing=YES;//允许编辑  从这个key UIImagePickerControllerEditedImage获取到图片
        UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
        //self.imageView.image = image;
        NSLog(@"image--image==%@\n",image);
        
        //_imagePicker.allowsEditing=NO;//不允许编辑  从这个key UIImagePickerControllerOriginalImage获取到图片
        UIImage *originalImage = info[UIImagePickerControllerOriginalImage];
        
        //NSString *tempVideoFileName2 = info[UIImagePickerControllerImageURL];//@"tempFnameStr";//[urlStr lastPathComponent];
//        NSString *fileNameStr3 = [tempVideoFileName2 lastPathComponent];
        
        NSData *tempImageData2 = UIImageJPEGRepresentation(originalImage, 1.0);
        NSDate *currentDate = [NSDate date];
        // 创建日期格式化器
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyyMMddHHmmssSSS"];
        
        // 格式化当前时间为年月日时分秒毫秒字符串
        NSString *datetimeString = [dateFormatter stringFromDate:currentDate];
        
        NSString *imageFileNameStr3 = [[NSString alloc] initWithFormat:@"%@.png", datetimeString];
        
        
        NSString *xsImagePathStr3 = [YSHelp bossIpWriteImageData:tempImageData2 withFileName:imageFileNameStr3];
        
        
        [YSHelp wqWriteData:[NSString stringWithFormat:@"xsPubilicFilePathStr---jkjkjkjk==imageFileNameStr3%@---xsImagePathStr3==%@---tempImageData2==%@",imageFileNameStr3,xsImagePathStr3,tempImageData2] withFileName:@"xsPubilicFilePathStr44444dgssgsdgds"];
        
        
        if(!kStringIsEmpty(xsImagePathStr3)){
            // typeStatu 2 图片 3视频
            //action  1返回上个页面  2002跳转到免费定制页面 2003返回图片或者视频的路径
           // [self fireEvent:@"onCallBack" params:@{@"detail":@{@"action":@"2003",@"xsFilePath":xsImagePathStr3,@"typeStatu":@"2"}} domChanges:nil];
            
            [YSHelp wqWriteData:[NSString stringWithFormat:@"xsPubilicFilePathStr---4444444==%@",xsImagePathStr3] withFileName:@"xsPubilicFilePathStr44444"];
        }
        else{
            [YSHelp wqWriteData:[NSString stringWithFormat:@"xsImagePathStr3---3333==%@",xsImagePathStr3] withFileName:@"xsVideoPathStr333333"];
        }
        
        
////    NSData *tempVideoFileData2 = [NSData dataWithContentsOfFile:tempVideoFileName2];
//        if(kStringIsEmpty(fileNameStr3)){
//            NSDate *currentDate = [NSDate date];
//            // 创建日期格式化器
//            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//            [dateFormatter setDateFormat:@"yyyyMMddHHmmssSSS"];
//
//            // 格式化当前时间为年月日时分秒毫秒字符串
//            NSString *datetimeString = [dateFormatter stringFromDate:currentDate];
//
//            NSString *timeLocal = [[NSString alloc] initWithFormat:@"%@.png", datetimeString];
//            fileNameStr3 = timeLocal;
//        }
//        NSData *tempVideoFileData2 =  UIImageJPEGRepresentation(originalImage, 1.0);
//    [self xsUploadImageWith:tempVideoFileData2 withName:fileNameStr3];
        
        int a = 10;
//
//           // 在这里对图片进行调整大小的操作
//           UIImage *resizedImage = [self resizeImage:originalImage toSize:CGSizeMake(newWidth, newHeight)];
//
//           // 在这里进行其他处理或展示调整大小后的图片
    }

    [picker dismissViewControllerAnimated:YES completion:nil];


}
- (UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size {
    UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return resizedImage;
}
// 点击取消按钮的回调方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [picker dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark  私有方法
- (UIImagePickerController *)imagePicker {

    if (!_imagePicker) {
        _imagePicker = [[UIImagePickerController alloc] init];
//        _imagePicker.allowsEditing=YES;//允许编辑
        _imagePicker.delegate=self;//设置代理，检测操作
        //_imagePicker.allowsImageEditing = YES;

    }
    return _imagePicker;
}


//视频保存后的回调
- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
    
    NSLog(@"videoPath--videoPath==%@\n",videoPath);
    if (error) {
        NSLog(@"保存视频过程中发生错误，错误信息:%@",error.localizedDescription);
    }else{
        NSLog(@"视频保存成功.");
//        //录制完之后自动播放
//        NSURL *url=[NSURL fileURLWithPath:videoPath];
//        _player=[AVPlayer playerWithURL:url];
//        AVPlayerLayer *playerLayer=[AVPlayerLayer playerLayerWithPlayer:_player];
//        playerLayer.frame=self.imageView.bounds;
//        [self.imageView.layer addSublayer:playerLayer];
//        [_player play];

    }
}

- (void)setType:(ImagePickerType)type {

    
    switch (type) {
        case ImagePickerTypePhotoLibrary:
        {
            self.imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];
            self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            break;
        }

        case ImagePickerTypePhotosAlbum:
        {
            self.imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];
            self.imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            break;
        }

        case ImagePickerTypeCameraPhoto:
        {
            self.imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];
            self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            self.imagePicker.cameraDevice=UIImagePickerControllerCameraDeviceFront;//设置使用哪个摄像头，这里设置为前置摄像头
            self.imagePicker.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;
            break;
        }

        case ImagePickerTypeCameraVideo:
        {
            self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            self.imagePicker.cameraDevice=UIImagePickerControllerCameraDeviceRear;//设置使用哪个摄像头，这里设置为后置摄像头

            self.imagePicker.mediaTypes=@[(NSString *)kUTTypeMovie];
            self.imagePicker.videoQuality=UIImagePickerControllerQualityTypeIFrame1280x720;
            self.imagePicker.cameraCaptureMode=UIImagePickerControllerCameraCaptureModeVideo;//设置摄像头模式（拍照，录制视频）
            break;
        }

        default:
            break;
    }
}


#pragma mark 弹出选择拍照 从相册获取图片 拍摄视频 end
#pragma mark -



- (void)xsUploadVideoWith:(NSData *)videoData withName:(NSString *)videoNameStr{
    //
        
        XSWeakSelf;

        
    NSString *tempUrl = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"disk/quickUpload"];
        
    NSDictionary *pramerDict = @{@"parentId":@"0",@"fileName":videoNameStr};
        
    [[ZYFDataManager sharedInstance] POST:tempUrl fileArr:@[videoData] parameterDictionay:pramerDict succeed:^(id data) {
        
        NSLog(@"quickUpload-pramerDict==%@--data==%@\n",pramerDict,data);
        
        NSDictionary *dictData = data;
        if([dictData isKindOfClass:[NSDictionary class]]){
            if([dictData[@"code"] isKindOfClass:[NSNumber class]]||[dictData[@"code"] isKindOfClass:[NSString class]]){
                NSInteger codeInt = [dictData[@"code"] integerValue];
                if(codeInt==200){
                    
                }
            }
        }
        
        
    } failure:^(NSDictionary *error) {
        NSLog(@"quickUpload--error.description==%@\n",error.description);
    }];
//    [[ZYFDataManager sharedInstance] GET:tempUrl dict:pramerDict succeed:^(id data) {} failure:^(NSDictionary *error) {}];
}

- (void)xsUploadImageWith:(NSData *)videoData withName:(NSString *)videoNameStr{
    //
        
        XSWeakSelf;

        
    NSString *tempUrl = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"disk/quickUpload"];
        
    NSDictionary *pramerDict = @{@"parentId":@"0",@"fileName":videoNameStr};
        
    [[ZYFDataManager sharedInstance] POST:tempUrl fileArr:@[videoData] parameterDictionay:pramerDict succeed:^(id data) {
        
        NSLog(@"quickUpload-pramerDict==%@--data==%@\n",pramerDict,data);
        
        NSDictionary *dictData = data;
        if([dictData isKindOfClass:[NSDictionary class]]){
            if([dictData[@"code"] isKindOfClass:[NSNumber class]]||[dictData[@"code"] isKindOfClass:[NSString class]]){
                NSInteger codeInt = [dictData[@"code"] integerValue];
                if(codeInt==200){
                    
                }
            }
        }
        
        
    } failure:^(NSDictionary *error) {
        NSLog(@"quickUpload--error.description==%@\n",error.description);
    }];
//    [[ZYFDataManager sharedInstance] GET:tempUrl dict:pramerDict succeed:^(id data) {} failure:^(NSDictionary *error) {}];
}


#pragma mark 获取老板ip数字人页面一进来就设置一张图片
// 视频比例 aspectRatio    视频比例 现在只有竖屏 传1就行   categoryId： 1是男的 2是女的 0是全部
- (void)getNumberPeopleDataWithAspectRatio:(NSInteger)aspectRatio withCategoryId:(NSInteger)categoryId
{
//
    
    XSWeakSelf;
   
    
    NSDictionary *pramerDict = @{@"page":@(1),
                                 @"limit":@"100",
                                 @"categoryId":[NSString stringWithFormat:@"%ld",categoryId],
                                 @"aspectRatio":[NSString stringWithFormat:@"%ld",aspectRatio]};
//    @"https://mall219.writemall.com/bossapi/digitalHuman/pageList"
    NSString *requestUrlString = [NSString stringWithFormat:@"%@%@",API_BASEURL_BossIP,@"digitalHuman/pageList"];
    [[ZYFDataManager sharedInstance] POST:requestUrlString dict:pramerDict succeed:^(id data) {
        
        
        if(categoryId==0){
            NSLog(@"老板IP模板-全部--data==%@\n",data);
        }
        else if(categoryId==1){
            NSLog(@"老板IP模板-男性--data==%@\n",data);
        }
        else if(categoryId==2){
            NSLog(@"老板IP模板-女性--data==%@\n",data);
        }
        
        NSDictionary *dictData = data;
        if([dictData isKindOfClass:[NSDictionary class]]){
            if([dictData[@"code"] isKindOfClass:[NSNumber class]]||[dictData[@"code"] isKindOfClass:[NSString class]]){
                NSInteger codeInt = [dictData[@"code"] integerValue];
                if(codeInt==200){
                    
                    if([dictData[@"data"] isKindOfClass:[NSDictionary class]]){
                        NSDictionary *dictData2 = dictData[@"data"];
                        if([dictData2[@"data"] isKindOfClass:[NSArray class]]){
                            NSArray *dataArr3  = dictData2[@"data"];
                            
                            if(dataArr3.count>0){
                                
                                NSDictionary *tempFinalDict = dataArr3.firstObject;
                                xsSelectDigitalRobotCollectionViewCellModel *md = [xsSelectDigitalRobotCollectionViewCellModel yy_modelWithDictionary:tempFinalDict];
                                
                                md.isClickFreeCustom = NO;
                                if([tempFinalDict[@"id"] isKindOfClass:[NSNumber class]]||
                                   [tempFinalDict[@"id"] isKindOfClass:[NSString class]]){
                                   NSString *tempIdStr = [NSString stringWithFormat:@"%ld",[tempFinalDict[@"id"] integerValue]];
                                    md.Id = [tempIdStr integerValue];
                                }
                                
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    [weakSelf xsChangeDigitalRobotIdAndpreviewImageWithModel:md];
                                });
                            }
                        }
                    }
                }
            }
        }
    } failure:^(NSDictionary *error) {
        NSLog(@"getDataWithType--error.description==%@\n",error.description);
    }];
}


- (NSMutableArray *)bossBackgroundImageZheZhaoMarr{
    
    //    bossBackgroundImageLeftView    tag=0
    //    bossBackgroundImageTopView     tag=1
    //    bossBackgroundImageRightView   tag=2
    //    bossBackgroundImageBottomView  tag=3
    //    topCenterView                  tag=4
    if(!_bossBackgroundImageZheZhaoMarr){
        _bossBackgroundImageZheZhaoMarr = [[NSMutableArray alloc] init];
    }
    return _bossBackgroundImageZheZhaoMarr;
}

// 记录底部显示的弹框
// tag  0老板IP  1配音  2背景  3文字  4音乐
- (NSMutableArray *)xsRecrodBottomShowPanViewMarray{
    
    if(!_xsRecrodBottomShowPanViewMarray){
        _xsRecrodBottomShowPanViewMarray = [[NSMutableArray alloc] init];
    }
    return _xsRecrodBottomShowPanViewMarray;
}


- (UIView *)topNavBarView{
    if(!_topNavBarView){
        _topNavBarView = [[UIView alloc] init];
        _topNavBarView.backgroundColor = UIColor.blackColor;
    }
    return _topNavBarView;
}
- (void)wqWriteData:(NSString *)contentString withFileName:(NSString *)fNameStr{
    
    [YSHelp wqWriteData:contentString withFileName:fNameStr];
}
@end

























